Files
briar/components/net/sf/briar/plugins/file/FileTransportWriter.java
akwizgran 99caec9448 Refactoring.
Unidirectional transports and connections are now called
simplex rather than batch. Bidirectional transports and connections
are now called duplex rather than stream.
2012-01-11 17:00:47 +00:00

51 lines
1.1 KiB
Java

package net.sf.briar.plugins.file;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.briar.api.plugins.SimplexTransportWriter;
class FileTransportWriter implements SimplexTransportWriter {
private static final Logger LOG =
Logger.getLogger(FileTransportWriter.class.getName());
private final File file;
private final OutputStream out;
private final long capacity;
private final FilePlugin plugin;
FileTransportWriter(File file, OutputStream out, long capacity,
FilePlugin plugin) {
this.file = file;
this.out = out;
this.capacity = capacity;
this.plugin = plugin;
}
public long getCapacity() {
return capacity;
}
public OutputStream getOutputStream() {
return out;
}
public boolean shouldFlush() {
return false;
}
public void dispose(boolean exception) {
try {
out.close();
} catch(IOException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
}
if(exception) file.delete();
else plugin.writerFinished(file);
}
}