/** * Overwrites a file with the contents of a byte array. * * <p><b>{@link java.nio.file.Path} equivalent:</b> {@link * java.nio.file.Files#write(java.nio.file.Path, byte[], java.nio.file.OpenOption...)}. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
/** * Overwrites a file with the contents of a byte array. * * <p><b>{@link java.nio.file.Path} equivalent:</b> {@link * java.nio.file.Files#write(java.nio.file.Path, byte[], java.nio.file.OpenOption...)}. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
/** * Overwrites a file with the contents of a byte array. * * <p><b>{@link java.nio.file.Path} equivalent:</b> {@link * java.nio.file.Files#write(java.nio.file.Path, byte[], java.nio.file.OpenOption...)}. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
public void testWrite() throws IOException { sink.write(data); assertContainsExpectedBytes(); }
closer.register(segmentWriteOutMedium); long startTime = System.currentTimeMillis(); Files.asByteSink(new File(outDir, "version.bin")).write(Ints.toByteArray(IndexIO.V9_VERSION)); log.info("Completed version.bin in %,d millis.", System.currentTimeMillis() - startTime);
@Before public void setUp() throws IOException { config = new LocalDataSegmentPusherConfig(); config.storageDirectory = temporaryFolder.newFolder(); localDataSegmentPusher = new LocalDataSegmentPusher(config, TestHelper.makeJsonMapper()); dataSegmentFiles = temporaryFolder.newFolder(); Files.asByteSink(new File(dataSegmentFiles, "version.bin")).write(Ints.toByteArray(0x9)); }
@Test public void testLastPushWinsForConcurrentPushes() throws IOException { File replicatedDataSegmentFiles = temporaryFolder.newFolder(); Files.asByteSink(new File(replicatedDataSegmentFiles, "version.bin")).write(Ints.toByteArray(0x8)); DataSegment returnSegment1 = localDataSegmentPusher.push(dataSegmentFiles, dataSegment, false); DataSegment returnSegment2 = localDataSegmentPusher.push(replicatedDataSegmentFiles, dataSegment2, false); Assert.assertEquals(dataSegment.getDimensions(), returnSegment1.getDimensions()); Assert.assertEquals(dataSegment2.getDimensions(), returnSegment2.getDimensions()); File unzipDir = new File(config.storageDirectory, "unzip"); FileUtils.forceMkdir(unzipDir); CompressionUtils.unzip( new File(config.storageDirectory, "/ds/1970-01-01T00:00:00.000Z_1970-01-01T00:00:00.001Z/v1/0/index.zip"), unzipDir ); Assert.assertEquals(0x8, Ints.fromByteArray(Files.toByteArray(new File(unzipDir, "version.bin")))); }
/** * Overwrites a file with the contents of a byte array. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
/** * Overwrites a file with the contents of a byte array. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
/** * Writes a byte array to an output stream from the given supplier. * * @param from the bytes to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static void write(byte[] from, OutputSupplier<? extends OutputStream> to) throws IOException { asByteSink(to).write(from); }
/** * Writes a byte array to an output stream from the given supplier. * * @param from the bytes to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static void write(byte[] from, OutputSupplier<? extends OutputStream> to) throws IOException { asByteSink(to).write(from); }
/** * Writes a byte array to an output stream from the given supplier. * * @param from the bytes to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static void write(byte[] from, OutputSupplier<? extends OutputStream> to) throws IOException { asByteSink(to).write(from); }
/** * Writes a byte array to an output stream from the given supplier. * * @param from the bytes to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static void write(byte[] from, OutputSupplier<? extends OutputStream> to) throws IOException { asByteSink(to).write(from); }
/** * Overwrites a file with the contents of a byte array. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
/** * Overwrites a file with the contents of a byte array. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
/** * Overwrites a file with the contents of a byte array. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
/** * Overwrites a file with the contents of a byte array. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
/** * Writes a byte array to an output stream from the given supplier. * * @param from the bytes to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static void write(byte[] from, OutputSupplier<? extends OutputStream> to) throws IOException { asByteSink(to).write(from); }
/** * Overwrites a file with the contents of a byte array. * * @param from the bytes to write * @param to the destination file * @throws IOException if an I/O error occurs */ public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); }
public void write(Credentials credentials) throws IOException, CredentialsEncryptionException { CredentialsEncrypter encrypter = new CredentialsEncrypter(); byte[] bytes = encrypter.encrypt(credentials); sink.write(bytes); } }