开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜