@Test public void safeFilenameWhitespaces() { assertEquals("Chuck Norris", IOUtils.toSafeFilename("Chuck\tNorris")); assertEquals("Chuck Norris", IOUtils.toSafeFilename("\u00A0Chuck\u00A0Norris\u00A0")); assertEquals("Chuck Norris", IOUtils.toSafeFilename("\u00A0\n\t\u000B\f\rChuck\nNorris\u202f")); assertEquals("This is a Chuck Norris roundkick, will Steven Segal survive Nope!", IOUtils.toSafeFilename( "This\u1680is\u180ea\u2000Chuck\u200aNorris\u202froundkick,\u205fwill\u3000Steven\fSegal\rsurvive?\u000BNope!")); }
public static String toSafeFilename(String input) { return defaultString(input).replaceAll("\\s|\\h", " ").replaceAll("[\0\f\t\n\r\\\\/:*?\\\"<>|]", "") .trim(); }
IOUtils { public static String toSafeFilename(String input) { return defaultString(input).replaceAll("\\s|\\h", " ").replaceAll("[\0\f\t\n\r\\\\/:*?\\\"<>|]", "") .trim(); } }
IOUtils { public static String toSafeFilename(String input) { return defaultString(input).replaceAll("\\s|\\h", " ").replaceAll("[\0\f\t\n\r\\\\/:*?\\\"<>|]", "") .trim(); } private  IOUtils(); }
IOUtils { public static String toSafeFilename(String input) { return defaultString(input).replaceAll("\\s|\\h", " ").replaceAll("[\0\f\t\n\r\\\\/:*?\\\"<>|]", "") .trim(); } private  IOUtils(); static File createTemporaryBuffer(TaskOutput taskOut); static File createTemporaryBuffer(); static File createTemporaryBuffer(String extension); static File createTemporaryBufferWithName(String filename); static File createTemporaryFolder(); static File findNewNameThatDoesNotExist(File output); static String shortenFilename(String name); static String toSafeFilename(String input); static String toStrictFilename(String input); }
IOUtils { public static String toSafeFilename(String input) { return defaultString(input).replaceAll("\\s|\\h", " ").replaceAll("[\0\f\t\n\r\\\\/:*?\\\"<>|]", "") .trim(); } private  IOUtils(); static File createTemporaryBuffer(TaskOutput taskOut); static File createTemporaryBuffer(); static File createTemporaryBuffer(String extension); static File createTemporaryBufferWithName(String filename); static File createTemporaryFolder(); static File findNewNameThatDoesNotExist(File output); static String shortenFilename(String name); static String toSafeFilename(String input); static String toStrictFilename(String input);  }