java.io.IOException: Stream closed
I try to copy mre files
for(int i = 0; i < 3; i++){
File outputFile =new File(path);
InputStream ins = this.getClass().getResourceAsStream("/"+_files[i]);
BufferedInputStream input =new BufferedInputStream(ins);
FileOutputStream outfile =new FileOutputStream(outputFile);
int read;
byte[] buffer =newbyte[4096];
while ((read=input.read(buffer))!=-1){
outfile.write(buffer, 0, read);
}
outfile.close();
input.close();
}
Exception
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
what shoud be the problem
public vpid copyImages(...)
{
for(int i = 0; i < 3; i++){
File outputFile = new File(path);
InputStream ins = this.getClass().getResourceAsStream("/"+_files[i]);
BufferedInputStream input = new BufferedInputStream(ins);
FileOutputStream outfile = new FileOutputStream(outputFile);
int read;
byte[] buffer = new byte[4096];
while ((read=input.read(buffer))!=-1){
outfile.write(buffer, 0, read);// line 1575
}
outfile.close();
input.close();
}
Exception
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at app.org.SQLFactory.copyImagesToIMGServer(SQLFactory.java:1575)
what shoud be the problem and how to resulve this problem
thanks
I did not close the steeam
this is the code
public vpid copyImages()
{
String [] _files ={"b1.jpg",b2.jpg,b3.jpg};
for(int i = 0; i < _files.length; i++){
File outputFile = new File(path);
InputStream ins = this.getClass().getResourceAsStream("/"+_files[i]);
BufferedInputStream input = new BufferedInputStream(ins);
FileOutputStream outfile = new FileOutputStream(outputFile);
int read;
byte[] buffer = new byte[4096];
while ((read=input.read(buffer))!=-1){
outfile.write(buffer, 0, read);// line 1575
}// end while
outfile.close();
input.close();
} // end for
Exception
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at app.org.SQLFactory.copyImagesToIMGServer(SQLFactory.java:1575)