InputStream in java
How to get InputStream
and size of File
type in servlet?
Previously i was using FileUpload
type which has getInputStream()
and getSize()
m开发者_开发技巧ethods, but now i have to use File
type for bulk upload. I have tried but File
type has no such methods.
Use File#length()
to get the size.
long size = file.length();
// ...
Use FileInputStream
constructor to create an InputStream
based on a given File
.
InputStream input = new FileInputStream(file);
// ...
See also the File
javadoc and the basic Java I/O tutorial.
精彩评论