(String path, String extension)
| 2283 | } |
| 2284 | |
| 2285 | static String updateExtension(String path, String extension) { |
| 2286 | if (path==null) return null; |
| 2287 | int dotIndex = path.lastIndexOf("."); |
| 2288 | int separatorIndex = path.lastIndexOf(File.separator); |
| 2289 | if (dotIndex>=0 && dotIndex>separatorIndex && (path.length()-dotIndex)<=5) { |
| 2290 | if (dotIndex+1<path.length() && Character.isDigit(path.charAt(dotIndex+1))) |
| 2291 | path += extension; |
| 2292 | else |
| 2293 | path = path.substring(0, dotIndex) + extension; |
| 2294 | } else |
| 2295 | path += extension; |
| 2296 | return path; |
| 2297 | } |
| 2298 | |
| 2299 | /** Saves a string as a file. Displays a file save dialog if |
| 2300 | 'path' is null or blank. Returns an error message |
no test coverage detected