public class FileReceiver extends Object implements Runnable, Closeable
receiver = new FileReceiver(Files.createTempFile("received_", ".zip"));
new Thread(receiver).start();
...
// receiving a file/finishing
if (transferBytesArrive) {
writeMessageBytesTo(receiver.getPipedOutputStream());
} else if(transferFinishedMessageArrives) {
IOUtils.closeQuietly(receiver.getPipedOutputStream());
receiver.waitUntilFinishedUninterruptably();
}
| Constructor and Description |
|---|
FileReceiver(Path root) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
Throwable |
getFailure() |
String |
getFailureMessage() |
PipedOutputStream |
getPipedOutputStream() |
Path |
getRoot() |
boolean |
isFinished() |
void |
run() |
boolean |
success() |
void |
waitUntilFinishedUninterruptably() |
public FileReceiver(Path root)
public PipedOutputStream getPipedOutputStream()
public void waitUntilFinishedUninterruptably()
public boolean isFinished()
public boolean success()
public String getFailureMessage()
public Throwable getFailure()
public Path getRoot()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2015 Formicary. All rights reserved.