/** * Opens a file for writing, overwriting the file if it already exists * * @param file the file to write to * @return the output stream to write to */ public static OutputStream openFileForWriting(final File file) { return openFileForWriting(file, false); }
/** * Opens a file for writing, overwriting the file if it already exists * * @param file the file to write to * @return the output stream to write to */ public static OutputStream openFileForWriting(final File file) { return openFileForWriting(file, false); }
/** * Opens a file for writing, overwriting the file if it already exists * * @param file the file to write to * @return the output stream to write to */ public static OutputStream openFileForWriting(final File file) { return openFileForWriting(file, false); }
/** * Preferred over PrintStream and PrintWriter because an exception is thrown on I/O error */ public static BufferedWriter openFileForBufferedWriting(final File file, final boolean append) { return new BufferedWriter(new OutputStreamWriter(openFileForWriting(file, append)), Defaults.NON_ZERO_BUFFER_SIZE); }
/** * Preferred over PrintStream and PrintWriter because an exception is thrown on I/O error */ public static BufferedWriter openFileForBufferedWriting(final File file, final boolean append) { return new BufferedWriter(new OutputStreamWriter(openFileForWriting(file, append)), Defaults.NON_ZERO_BUFFER_SIZE); }
/** * Preferred over PrintStream and PrintWriter because an exception is thrown on I/O error */ public static BufferedWriter openFileForBufferedUtf8Writing(final File file) { return new BufferedWriter(new OutputStreamWriter(openFileForWriting(file), Charset.forName("UTF-8")), Defaults.NON_ZERO_BUFFER_SIZE); }
/** * Preferred over PrintStream and PrintWriter because an exception is thrown on I/O error */ public static BufferedWriter openFileForBufferedWriting(final File file, final boolean append) { return new BufferedWriter(new OutputStreamWriter(openFileForWriting(file, append)), Defaults.NON_ZERO_BUFFER_SIZE); }
/** * Preferred over PrintStream and PrintWriter because an exception is thrown on I/O error */ public static BufferedWriter openFileForBufferedUtf8Writing(final File file) { return new BufferedWriter(new OutputStreamWriter(openFileForWriting(file), Charset.forName("UTF-8")), Defaults.NON_ZERO_BUFFER_SIZE); }
/** * Preferred over PrintStream and PrintWriter because an exception is thrown on I/O error */ public static BufferedWriter openFileForBufferedUtf8Writing(final File file) { return new BufferedWriter(new OutputStreamWriter(openFileForWriting(file), Charset.forName("UTF-8")), Defaults.NON_ZERO_BUFFER_SIZE); }
private static OutputStream maybeMd5Wrap(final File file, final boolean createMd5) { if (createMd5) { return IOUtil.openFileForMd5CalculatingWriting(file); } else { return IOUtil.openFileForWriting(file); } } }
private static OutputStream maybeMd5Wrap(final File file, final boolean createMd5) { if (createMd5) { return IOUtil.openFileForMd5CalculatingWriting(file); } else { return IOUtil.openFileForWriting(file); } } }
private static OutputStream maybeMd5Wrap(final File file, final boolean createMd5) { if (createMd5) { return IOUtil.openFileForMd5CalculatingWriting(file); } else { return IOUtil.openFileForWriting(file); } } }
public NonFlushingBasicFastqWriter(final File file) { this(file, IOUtil.maybeBufferOutputStream(IOUtil.openFileForWriting(file))); }
public static OutputStream openFileForMd5CalculatingWriting(final File file) { return new Md5CalculatingOutputStream(IOUtil.openFileForWriting(file), new File(file.getAbsolutePath() + ".md5")); }
public static OutputStream openFileForMd5CalculatingWriting(final File file) { return new Md5CalculatingOutputStream(IOUtil.openFileForWriting(file), new File(file.getAbsolutePath() + ".md5")); }
public static OutputStream openFileForMd5CalculatingWriting(final File file) { return new Md5CalculatingOutputStream(IOUtil.openFileForWriting(file), new File(file.getAbsolutePath() + ".md5")); }
@Test public void testFileOpenInputStream() throws IOException{ File tempFile = File.createTempFile(getClass().getSimpleName(), ".tmp"); tempFile.deleteOnExit(); OutputStream os = IOUtil.openFileForWriting(tempFile); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os)); writer.write("hello"); writer.close(); tstStream(tempFile.getAbsolutePath()); tstStream(tempFile.toURI().toString()); }
@Test public void testFileReadingAndWriting() throws IOException { String randomizedTestString = TEST_STRING + System.currentTimeMillis(); for (String ext : TEST_FILE_EXTENSIONS) { File f = File.createTempFile(TEST_FILE_PREFIX, ext); f.deleteOnExit(); OutputStream os = IOUtil.openFileForWriting(f); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os)); writer.write(randomizedTestString); writer.close(); InputStream is = IOUtil.openFileForReading(f); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line = reader.readLine(); Assert.assertEquals(randomizedTestString, line); } }
/** * Closes any the open bfq file(s), if any, and opens the new one(s) * * @param fileIndex the index (counter) of the files to write */ private void initializeNextBfqFiles(final int fileIndex) { // Close the codecs if they were writing before if (codec1 != null) { codec1.close(); if (pairedReads) { codec2.close(); } } // Open new file, using the fileIndex. final File bfq1 = getOutputFile(this.outputPrefix , 1, fileIndex); codec1 = new BinaryCodec(IOUtil.openFileForWriting(bfq1)); log.info("Now writing to file " + bfq1.getAbsolutePath()); if (pairedReads) { final File bfq2 = getOutputFile(this.outputPrefix , 2, fileIndex); codec2 = new BinaryCodec(IOUtil.openFileForWriting(bfq2)); log.info("Now writing to file " + bfq2.getAbsolutePath()); } }
/** * Closes any the open bfq file(s), if any, and opens the new one(s) * * @param fileIndex the index (counter) of the files to write */ private void initializeNextBfqFiles(final int fileIndex) { // Close the codecs if they were writing before if (codec1 != null) { codec1.close(); if (pairedReads) { codec2.close(); } } // Open new file, using the fileIndex. final File bfq1 = getOutputFile(this.outputPrefix , 1, fileIndex); codec1 = new BinaryCodec(IOUtil.openFileForWriting(bfq1)); log.info("Now writing to file " + bfq1.getAbsolutePath()); if (pairedReads) { final File bfq2 = getOutputFile(this.outputPrefix , 2, fileIndex); codec2 = new BinaryCodec(IOUtil.openFileForWriting(bfq2)); log.info("Now writing to file " + bfq2.getAbsolutePath()); } }