开发者

InputStream in java

开发者 https://www.devze.com 2023-03-23 14:09 出处:网络
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 bu

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消