[英]Use Input Stream multiple times
for (File fileEntry : dir.listFiles()) {
String strXMLFilename = null;
strXMLFilename = fileEntry.getName();
InputStream input = new FileInputStream(strXMLFilename);
PostMethod post = new PostMethod();
post.setRequestBody(input);
.....
.....
.....
}
when ever my for loop runs, InputStream input = new FileInputStream(strXMLFilename);
每当我的for循环运行时,
InputStream input = new FileInputStream(strXMLFilename);
this line works fine. 这条线工作正常。 But, when the second time it is entering in to for block the re is a problem with this line.
但是,当第二次进入阻塞状态时,这条线是一个问题。 I hope the input stream is not reading the file properly.
我希望输入流不能正确读取文件。 i tried by closing the input stream, even though it is not working.
我尝试通过关闭输入流,即使它不起作用。
如果您想多次阅读它,则应该在读取BufferedInputStream之后使用reset方法,或者使用我认为更合适的byte []。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.