@Test public void testExpandFilePath() { final String FILE_SEP_KEY = "file.separator"; final String TEMP_DIR_KEY = "java.io.tmpdir"; String orgSeparator = System.getProperty(FILE_SEP_KEY); String orgTmpFile = System.getProperty(TEMP_DIR_KEY); try { System.setProperty(FILE_SEP_KEY, "/"); System.setProperty(TEMP_DIR_KEY, "/temp/"); assertEquals("/temp/some/path", IOUtil.expandFilePath("java.io.tmpdir/some/path")); assertEquals("/temp/", IOUtil.expandFilePath("java.io.tmpdir")); System.setProperty(FILE_SEP_KEY, "\\"); System.setProperty(TEMP_DIR_KEY, "C:\\WINNT\\TEMP\\"); assertEquals("C:\\WINNT\\TEMP\\some\\path", IOUtil.expandFilePath("java.io.tmpdir/some/path")); assertEquals("C:\\WINNT\\TEMP\\", IOUtil.expandFilePath("java.io.tmpdir")); } finally { System.setProperty(FILE_SEP_KEY, orgSeparator); System.setProperty(TEMP_DIR_KEY, orgTmpFile); } }
public static String expandFilePath(String path) { String tmpDir = System.getProperty(JAVA_TMP_KEY); path = path.trim(); if (path.length() > JAVA_TMP_KEY.length() && tmpDir.endsWith(System.getProperty("file.separator"))) { tmpDir = tmpDir.substring(0, tmpDir.length() - 1); } path = path.replace((CharSequence)JAVA_TMP_KEY, (CharSequence)tmpDir); path = path.replace('/', System.getProperty("file.separator").charAt(0)); return path; }
IOUtil { public static String expandFilePath(String path) { String tmpDir = System.getProperty(JAVA_TMP_KEY); path = path.trim(); if (path.length() > JAVA_TMP_KEY.length() && tmpDir.endsWith(System.getProperty("file.separator"))) { tmpDir = tmpDir.substring(0, tmpDir.length() - 1); } path = path.replace((CharSequence)JAVA_TMP_KEY, (CharSequence)tmpDir); path = path.replace('/', System.getProperty("file.separator").charAt(0)); return path; } }
IOUtil { public static String expandFilePath(String path) { String tmpDir = System.getProperty(JAVA_TMP_KEY); path = path.trim(); if (path.length() > JAVA_TMP_KEY.length() && tmpDir.endsWith(System.getProperty("file.separator"))) { tmpDir = tmpDir.substring(0, tmpDir.length() - 1); } path = path.replace((CharSequence)JAVA_TMP_KEY, (CharSequence)tmpDir); path = path.replace('/', System.getProperty("file.separator").charAt(0)); return path; } private  IOUtil(); }
IOUtil { public static String expandFilePath(String path) { String tmpDir = System.getProperty(JAVA_TMP_KEY); path = path.trim(); if (path.length() > JAVA_TMP_KEY.length() && tmpDir.endsWith(System.getProperty("file.separator"))) { tmpDir = tmpDir.substring(0, tmpDir.length() - 1); } path = path.replace((CharSequence)JAVA_TMP_KEY, (CharSequence)tmpDir); path = path.replace('/', System.getProperty("file.separator").charAt(0)); return path; } private  IOUtil(); static String getUTF8ResourceAsString(String path); static String getResourceAsString(String path, Charset encoding); static String toString(InputStream input, Charset encoding); static String expandDirectoryPath(String path); static String expandFilePath(String path); }
IOUtil { public static String expandFilePath(String path) { String tmpDir = System.getProperty(JAVA_TMP_KEY); path = path.trim(); if (path.length() > JAVA_TMP_KEY.length() && tmpDir.endsWith(System.getProperty("file.separator"))) { tmpDir = tmpDir.substring(0, tmpDir.length() - 1); } path = path.replace((CharSequence)JAVA_TMP_KEY, (CharSequence)tmpDir); path = path.replace('/', System.getProperty("file.separator").charAt(0)); return path; } private  IOUtil(); static String getUTF8ResourceAsString(String path); static String getResourceAsString(String path, Charset encoding); static String toString(InputStream input, Charset encoding); static String expandDirectoryPath(String path); static String expandFilePath(String path);  }