| 708 | private void writeToFile(File filename, String text) throws IOException { |
| 709 | filename = sanitizeName(filename); |
| 710 | final File finalFilename = filename; |
| 711 | Log.log("io.general", () -> " will write :" + text + " to " + finalFilename); |
| 712 | |
| 713 | if (!filename.getParentFile().exists()) filename.getParentFile().mkdirs(); |
| 714 | |
| 715 | filesTouched.add(filename); |
| 716 | |
| 717 | BufferedWriter w = new BufferedWriter(new FileWriter(filename)); |
| 718 | w.append(text); |
| 719 | w.close(); |
| 720 | } |
| 721 | |
| 722 | static private File sanitizeName(File filename) { |
| 723 | String f = filename.getName(); |
| 724 | f = f.replaceAll(">", "_"); |
| 725 | f = f.replaceAll("\\?", "_query_"); |
| 726 | f = f.replaceAll("\\*", "_star_"); |
| 727 | f = f.replaceAll("\\:", "_colon_"); |
| 728 | f = f.replaceAll("\\\\", "_backslash_"); |