@Test public void testSaveCommandHistory() throws IOException { int[] command1 = new int[]{99,108,115}; File targetFile = temporaryFolder.newFile("targetFile.txt"); FileUtils.saveCommandHistory(TestUtils.newArrayList(command1), targetFile); TestUtils.assertEqualContent("cls\n".getBytes(), targetFile); }
public static void saveCommandHistory(List<int[]> history, File file) { OutputStream out = null; try { out = new BufferedOutputStream(openOutputStream(file, false)); for (int[] command: history) { for (int i : command) { out.write(i); } out.write('\n'); } } catch (IOException e) { } finally { try { if (out != null) { out.close(); } } catch (IOException ioe) { } } }
FileUtils { public static void saveCommandHistory(List<int[]> history, File file) { OutputStream out = null; try { out = new BufferedOutputStream(openOutputStream(file, false)); for (int[] command: history) { for (int i : command) { out.write(i); } out.write('\n'); } } catch (IOException e) { } finally { try { if (out != null) { out.close(); } } catch (IOException ioe) { } } } }
FileUtils { public static void saveCommandHistory(List<int[]> history, File file) { OutputStream out = null; try { out = new BufferedOutputStream(openOutputStream(file, false)); for (int[] command: history) { for (int i : command) { out.write(i); } out.write('\n'); } } catch (IOException e) { } finally { try { if (out != null) { out.close(); } } catch (IOException ioe) { } } }  }
FileUtils { public static void saveCommandHistory(List<int[]> history, File file) { OutputStream out = null; try { out = new BufferedOutputStream(openOutputStream(file, false)); for (int[] command: history) { for (int i : command) { out.write(i); } out.write('\n'); } } catch (IOException e) { } finally { try { if (out != null) { out.close(); } } catch (IOException ioe) { } } }  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 void saveCommandHistory(List<int[]> history, File file) { OutputStream out = null; try { out = new BufferedOutputStream(openOutputStream(file, false)); for (int[] command: history) { for (int i : command) { out.write(i); } out.write('\n'); } } catch (IOException e) { } finally { try { if (out != null) { out.close(); } } catch (IOException ioe) { } } }  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);  }