@Test @SuppressWarnings("unused") public void write() throws IOException { File file = File.createTempFile("test", "tmp"); Assert.assertTrue(file.isFile()); try { FileUtils.write(file, "Hello world".getBytes("UTF-8")); byte[] data = FileUtils.readAllBytes(file); Assert.assertNotNull(data); String s = new String(data, "UTF-8"); Assert.assertEquals("Hello world", s); } finally { boolean ignored = file.delete(); } }
public static void write(File path, byte[] bytes) throws IOException { if (path.delete() && LOGGER.isDebugEnabled()) { LOGGER.debug("Removed " + path.getPath() + " during writing"); } try (FileOutputStream stream = new FileOutputStream(path)) { stream.write(bytes); stream.flush(); try { stream.getFD().sync(); } catch (SyncFailedException ignored) { } } }
FileUtils { public static void write(File path, byte[] bytes) throws IOException { if (path.delete() && LOGGER.isDebugEnabled()) { LOGGER.debug("Removed " + path.getPath() + " during writing"); } try (FileOutputStream stream = new FileOutputStream(path)) { stream.write(bytes); stream.flush(); try { stream.getFD().sync(); } catch (SyncFailedException ignored) { } } } }
FileUtils { public static void write(File path, byte[] bytes) throws IOException { if (path.delete() && LOGGER.isDebugEnabled()) { LOGGER.debug("Removed " + path.getPath() + " during writing"); } try (FileOutputStream stream = new FileOutputStream(path)) { stream.write(bytes); stream.flush(); try { stream.getFD().sync(); } catch (SyncFailedException ignored) { } } }  }
FileUtils { public static void write(File path, byte[] bytes) throws IOException { if (path.delete() && LOGGER.isDebugEnabled()) { LOGGER.debug("Removed " + path.getPath() + " during writing"); } try (FileOutputStream stream = new FileOutputStream(path)) { stream.write(bytes); stream.flush(); try { stream.getFD().sync(); } catch (SyncFailedException ignored) { } } }  static byte[] readAllBytes(File src); static void write(File path, byte[] bytes); @SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE") static void copy(File src, File dest); }
FileUtils { public static void write(File path, byte[] bytes) throws IOException { if (path.delete() && LOGGER.isDebugEnabled()) { LOGGER.debug("Removed " + path.getPath() + " during writing"); } try (FileOutputStream stream = new FileOutputStream(path)) { stream.write(bytes); stream.flush(); try { stream.getFD().sync(); } catch (SyncFailedException ignored) { } } }  static byte[] readAllBytes(File src); static void write(File path, byte[] bytes); @SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE") static void copy(File src, File dest);  }