Creates a temporary file based on the name/extension of another file and in the same parent directory. Ensures that the same extension is used (i.e. so that .gz files are gzip compressed on output) and that it's done from the same directory so that renaming the file later won't cross file system bou
(File file)
| 7817 | * system boundaries. |
| 7818 | */ |
| 7819 | static private File createTempFile(File file) throws IOException { |
| 7820 | File parentDir = file.getParentFile(); |
| 7821 | if (!parentDir.exists()) { |
| 7822 | parentDir.mkdirs(); |
| 7823 | } |
| 7824 | String name = file.getName(); |
| 7825 | String prefix; |
| 7826 | String suffix = null; |
| 7827 | int dot = name.lastIndexOf('.'); |
| 7828 | if (dot == -1) { |
| 7829 | prefix = name; |
| 7830 | } else { |
| 7831 | // preserve the extension so that .gz works properly |
| 7832 | prefix = name.substring(0, dot); |
| 7833 | suffix = name.substring(dot); |
| 7834 | } |
| 7835 | // Prefix must be three characters |
| 7836 | if (prefix.length() < 3) { |
| 7837 | prefix += "processing"; |
| 7838 | } |
| 7839 | return File.createTempFile(prefix, suffix, parentDir); |
| 7840 | } |
| 7841 | |
| 7842 | |
| 7843 | /** |