Utils { public static String getFile(String FileName) { StringBuffer buffer = new StringBuffer(); try { BufferedReader dataInput = new BufferedReader(new FileReader( new File(FileName))); String line; while ((line = dataInput.readLine()) != null) { buffer.append(line); if (dataInput.ready()) { buffer.append('\n'); } } dataInput.close(); } catch (Exception ex) { ex.printStackTrace(); } return buffer.toString(); }  static String cleanLine(String line); static String getFile(String FileName); static void writeFile(String in, String filename); static Double round(double d, int decimalPlace); static Double entropy(double[] p);  }
@Test public final void testGetFile() { String data = "test\nrow2\nLast row."; String property = "java.io.tmpdir"; String fname = new String("dfgdfsgdfshfr.txt"); String fullpath = System.getProperty(property)+File.separatorChar+fname; File toCheck = new File(fullpath); if (toCheck.exists()) toCheck.delete(); BufferedWriter bw; try { bw = new BufferedWriter(new FileWriter(toCheck)); bw.write(data); bw.close(); } catch (IOException e) { fail(e.getMessage()); }; String fgetFileReturned = Utils.getFile(fullpath); int isTheSameContent = data.compareTo(fgetFileReturned); System.out.println("In=["+data+"]"); System.out.println("Out=["+fgetFileReturned+"]"); toCheck.delete(); assertTrue("getFile adds new line at the end. Len in="+ data.length()+", Len out="+fgetFileReturned.length(),isTheSameContent==0); }