Package net.sf.basedb.core
Class File.UploadStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.BufferedOutputStream
net.sf.basedb.core.File.UploadStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Enclosing class:
- File
This class is used for uploading a file. It keeps track of the number
of bytes uploaded and sets the size accordingly.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
If the md5 should be checked or not.private boolean
If this file closed or not.private boolean
If the file should be compressed or not.private File
The file to write to.private MessageDigest
The md5 sum calculater.private long
Number of bytes written to the stream.private File.CharsetTesterThread
Fields inherited from class java.io.BufferedOutputStream
buf, count
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ModifierConstructorDescriptionprivate
UploadStream
(File file, boolean calculateMd5, boolean checkMd5, boolean compress, boolean utf8Detect) Create a newUploadStream
and connect it to the given file. -
Method Summary
Methods inherited from class java.io.BufferedOutputStream
flush
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
closed
private boolean closedIf this file closed or not. -
totalBytes
private long totalBytesNumber of bytes written to the stream. -
md5
The md5 sum calculater. -
file
The file to write to. -
compress
private boolean compressIf the file should be compressed or not. -
checkMd5
private boolean checkMd5If the md5 should be checked or not. -
utf8Tester
-
-
Constructor Details
-
UploadStream
private UploadStream(File file, boolean calculateMd5, boolean checkMd5, boolean compress, boolean utf8Detect) throws IOException Create a newUploadStream
and connect it to the given file.- Parameters:
file
- The physical file path to which the stream will writecalculateMd5
- TRUE if an md5 sum should be calculated from this uploadstreamcheckMd5
- If the md5 sum of the file should be checked agains the previously stored md5 sum, useful for making sure secondary storage is working properlyutf8Detect
- If set, we try to parse the file as UTF-8. If this works we set the encoding to UTF-8- Throws:
IOException
- If there is an error during the upload
-
-
Method Details
-
write
- Overrides:
write
in classBufferedOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
Writes the specified byte to this buffered output stream.- Overrides:
write
in classBufferedOutputStream
- Parameters:
b
- the byte to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
-
close
Close the stream and register the size and location with the file item.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
- if an I/O error occurs.
-