@Override public OutputStream create(String entry) throws IOException { return new TFileOutputStream(entry); } });
@SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION") final void write(final Node node, final byte[] code) throws IOException { final OutputStream out = new TFileOutputStream(node.file()); try { out.write(code); } finally { out.close(); } } }
/** * Constructs a new {@code TFile} writer. * * @param file a file to write. * @param append iff {@code true}, then this writer appends the data to the * given file. * @param charset a character set for encoding characters to bytes. * @throws FileNotFoundException on any I/O failure. * @since TrueZIP 7.5 */ @CreatesObligation @edu.umd.cs.findbugs.annotations.SuppressWarnings("OBL_UNSATISFIED_OBLIGATION") public TFileWriter(File file, boolean append, Charset charset) throws FileNotFoundException { super(new TFileOutputStream(file, append), charset); }
/** * Constructs a new {@code TFile} writer. * This writer uses the default character set for encoding characters * to bytes. * * @param file a file to write. * @throws FileNotFoundException on any I/O failure. */ @CreatesObligation @edu.umd.cs.findbugs.annotations.SuppressWarnings({ "DM_DEFAULT_ENCODING", "OBL_UNSATISFIED_OBLIGATION" }) public TFileWriter(File file) throws FileNotFoundException { super(new TFileOutputStream(file)); }
/** * Constructs a new {@code TFile} writer. * <p> * TODO: Remove this redundant constructor in TrueZIP 8. * * @param file a file to write. * @param append iff {@code true}, then this writer appends the data to the * given file. * @param encoder an encoder for encoding characters to bytes. * @throws FileNotFoundException on any I/O failure. */ @CreatesObligation @edu.umd.cs.findbugs.annotations.SuppressWarnings("OBL_UNSATISFIED_OBLIGATION") public TFileWriter(TFile file, boolean append, CharsetEncoder encoder) throws FileNotFoundException { super(new TFileOutputStream(file, append), encoder); }
/** * Constructs a new {@code TFile} writer. * * @param file a file to write. * @param append iff {@code true}, then this writer appends the data to the * given file. * @param encoder an encoder for encoding characters to bytes. * @throws FileNotFoundException on any I/O failure. */ @CreatesObligation @edu.umd.cs.findbugs.annotations.SuppressWarnings("OBL_UNSATISFIED_OBLIGATION") public TFileWriter(File file, boolean append, CharsetEncoder encoder) throws FileNotFoundException { super(new TFileOutputStream(file, append), encoder); }
/** * Constructs a new {@code TFile} writer. * This writer uses the default character set for encoding characters * to bytes. * <p> * TODO: Remove this redundant constructor in TrueZIP 8. * * @param file a file to write. * @throws FileNotFoundException on any I/O failure. */ @CreatesObligation @edu.umd.cs.findbugs.annotations.SuppressWarnings({ "DM_DEFAULT_ENCODING", "OBL_UNSATISFIED_OBLIGATION" }) public TFileWriter(TFile file) throws FileNotFoundException { super(new TFileOutputStream(file)); }
/** * Constructs a new {@code TFile} writer. * This writer uses the default character set for encoding characters * to bytes. * <p> * TODO: Remove this redundant constructor in TrueZIP 8. * * @param file a file to write. * @param append iff {@code true}, then this writer appends the data to the * given file. * @throws FileNotFoundException on any I/O failure. */ @CreatesObligation @edu.umd.cs.findbugs.annotations.SuppressWarnings({ "DM_DEFAULT_ENCODING", "OBL_UNSATISFIED_OBLIGATION" }) public TFileWriter(TFile file, boolean append) throws FileNotFoundException { super(new TFileOutputStream(file, append)); }
/** * Constructs a new {@code TFile} writer. * This writer uses the default character set for encoding characters * to bytes. * * @param file a file to write. * @param append iff {@code true}, then this writer appends the data to the * given file. * @throws FileNotFoundException on any I/O failure. */ @CreatesObligation @edu.umd.cs.findbugs.annotations.SuppressWarnings({ "DM_DEFAULT_ENCODING", "OBL_UNSATISFIED_OBLIGATION" }) public TFileWriter(File file, boolean append) throws FileNotFoundException { super(new TFileOutputStream(file, append)); }
protected final void createTestFile(final TFile file) throws IOException { final OutputStream out = new TFileOutputStream(file); try { out.write(getData()); } finally { out.close(); } }
@Test public final void testRenameValidArchive() throws IOException { // Create a regular archive with a single archive entry which // contains a creative greeting message. PrintStream out = new PrintStream( new TFileOutputStream(new TFile(archive, "entry"))); try { out.println("Hello World!"); } finally { out.close(); // ALWAYS close streams! } assertRenameArchiveToTemp(archive); }
private void roundTrip() throws IOException { final TFile file = new TFile(archive, "entry"); final OutputStream os = new TFileOutputStream(file); try { os.write(data); } finally { os.close(); } final ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length); final InputStream is = new TFileInputStream(file); try { TFile.cat(is, baos); } finally { is.close(); } Arrays.equals(data, baos.toByteArray()); } }
TFileOutputStream os = new TFileOutputStream(file); try
private void create(final TFile file) throws IOException { final OutputStream out = new TFileOutputStream(file); try { out.write(getData()); } finally { out.close(); } assertEquals(getDataLength(), file.length()); }
/** * Encrypts the given plain file to the given RAES file, * using the provided TArchiveDetector to detect any archive files in its * parent directory path except the files themselves, which are not * recognized as archive files. */ @edu.umd.cs.findbugs.annotations.SuppressWarnings("OBL_UNSATISFIED_OBLIGATION") public static void encrypt( final String plainFilePath, final String raesFilePath, final TArchiveDetector detector) throws IOException { final TFile plainFile = newNonArchiveFile(plainFilePath, detector); final TFile raesFile = newNonArchiveFile(raesFilePath, detector); final RaesParameters params = new KeyManagerRaesParameters( KeyManagerLocator.SINGLETON, raesFile/*.getCanonicalFile()*/.toURI()); final InputStream in = new TFileInputStream(plainFile); RaesOutputStream out = null; try { out = RaesOutputStream.getInstance( new TFileOutputStream(raesFile, false), params); } finally { if (null == out) // exception? in.close(); } TFile.cp(in, out); }
OutputStream os = new TFileOutputStream(file); try
OutputStream out = null; try { out = new TFileOutputStream(plainFile, false); } finally { if (null == out) // exception?
public ScreenshotMeta addScreenshot(final String testClass, final String testMethod, final String screenshotId, final String url, final String title, final File file) throws IOException { String pngPath = getPath(testClass, testMethod, screenshotId, ".png"); String propPath = getPath(testClass, testMethod, screenshotId, ".properties"); TFile fileInArchive = new TFile(this.archive, pngPath); // copy screenshot file to archive new TFile(file).cp(fileInArchive); ScreenshotMeta meta = new ScreenshotMeta(testClass, testMethod, screenshotId, url, title, fileInArchive.getInnerEntryName()); TFileOutputStream out = new TFileOutputStream(new TFile(this.archive, propPath)); try { meta.store(out); } finally { out.close(); } return meta; }
new TFileOutputStream(dir).close(); fail(); } catch (FileNotFoundException expected) {
private void assertFileOutputStream(final TFile file) throws IOException { final byte[] message = "Hello World!\r\n".getBytes(); final OutputStream out = new TFileOutputStream(file); try { assertTrue(file.exists());