FileUtils { public static String appendSlash(String s) { if (s == null) { return null; } s = s.trim(); if (s.endsWith("/")) { return s; } else { return s + "/"; } } private  FileUtils(); static void appendContentsTofile(String fileName, String contents); static String appendSlash(String s); @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="OBL_UNSATISFIED_OBLIGATION") static boolean bcmp(String fn1, String fn2); static boolean checkFileExists(String fileName); static void copy(InputStream in, OutputStream out); static void copyFile(String src, String dst); @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="OBL_UNSATISFIED_OBLIGATION") static void cp(String src, String dst); static void createFileAndWriteContents(String fileName, String contents); static void createPath(String path, boolean mustCreate); static File createTempPath(String path); static boolean dirExists(String fName); static boolean emptyDir(String dirName); static boolean fileExists(String fName); static byte[] fileToByteArray(String fname); static String readFile(String fileName, String newLine); static String readFileOrNull(String fileName); static void writeLine(BufferedWriter out, String line); @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="REC_CATCH_EXCEPTION") static boolean writeLine(String outFname, String line, boolean append); static void xcopy(String src, String dst);  }
@Test public void testAppendSlash(){ assertEquals("test/", FileUtils.appendSlash("test")); assertEquals("test/", FileUtils.appendSlash("test/")); assertEquals(null, FileUtils.appendSlash(null)); }