@Test public void testLoadCommandHistory() throws IOException { int[] command1 = new int[]{99,108,115}; File targetFile = temporaryFolder.newFile("targetFile.txt"); FileUtils.saveCommandHistory(TestUtils.newArrayList(command1), targetFile); List<int[]> content = FileUtils.loadCommandHistory(targetFile); Assert.assertArrayEquals(command1, content.get(0)); }
public static List<int[]> loadCommandHistory(File file) { BufferedReader br = null; List<int[]> history = new ArrayList<int[]>(); try { br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line; while ((line = br.readLine()) != null) { history.add(Helper.toCodePoints(line)); } } catch (IOException e) { } finally { try { if (br != null) { br.close(); } } catch (IOException ioe) { } } return history; }
FileUtils { public static List<int[]> loadCommandHistory(File file) { BufferedReader br = null; List<int[]> history = new ArrayList<int[]>(); try { br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line; while ((line = br.readLine()) != null) { history.add(Helper.toCodePoints(line)); } } catch (IOException e) { } finally { try { if (br != null) { br.close(); } } catch (IOException ioe) { } } return history; } }
FileUtils { public static List<int[]> loadCommandHistory(File file) { BufferedReader br = null; List<int[]> history = new ArrayList<int[]>(); try { br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line; while ((line = br.readLine()) != null) { history.add(Helper.toCodePoints(line)); } } catch (IOException e) { } finally { try { if (br != null) { br.close(); } } catch (IOException ioe) { } } return history; }  }
FileUtils { public static List<int[]> loadCommandHistory(File file) { BufferedReader br = null; List<int[]> history = new ArrayList<int[]>(); try { br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line; while ((line = br.readLine()) != null) { history.add(Helper.toCodePoints(line)); } } catch (IOException e) { } finally { try { if (br != null) { br.close(); } } catch (IOException ioe) { } } return history; }  static void writeByteArrayToFile(File file, byte[] data); static void writeByteArrayToFile(File file, byte[] data, boolean append); static FileOutputStream openOutputStream(File file, boolean append); static void saveCommandHistory(List<int[]> history, File file); static List<int[]> loadCommandHistory(File file); static void saveCommandHistoryString(List<String> history, File file); static List<String> loadCommandHistoryString(File file); static String readFileToString(File file, Charset encoding); static Properties readProperties(String file); }
FileUtils { public static List<int[]> loadCommandHistory(File file) { BufferedReader br = null; List<int[]> history = new ArrayList<int[]>(); try { br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line; while ((line = br.readLine()) != null) { history.add(Helper.toCodePoints(line)); } } catch (IOException e) { } finally { try { if (br != null) { br.close(); } } catch (IOException ioe) { } } return history; }  static void writeByteArrayToFile(File file, byte[] data); static void writeByteArrayToFile(File file, byte[] data, boolean append); static FileOutputStream openOutputStream(File file, boolean append); static void saveCommandHistory(List<int[]> history, File file); static List<int[]> loadCommandHistory(File file); static void saveCommandHistoryString(List<String> history, File file); static List<String> loadCommandHistoryString(File file); static String readFileToString(File file, Charset encoding); static Properties readProperties(String file);  }