i am working in copying file to other destination.my code doesnt work as expected.can anybody help me.i got this error message --->
java.io.FileNot FoundException: C:\Documents and Settings\XXXXXX X\My Documents (Access is denied)
at java.io.FileOut putStream.open( Native Method)
at java.io.FileOut putStream.<init >(FileOutputStr eam.java:179)
at java.io.FileOut putStream.<init >(FileOutputStr eam.java:131)
at test1.PilihFail $Salin2.run(Pil ihFail.java:111 )
the code is:
private int currentValue;
public void run(){
BufferedInputSt ream in = null;
BufferedOutputS tream out = null;
try{
File inFile = new File(jtfOpen.ge tText().trim()) ;
in = new BufferedInputSt ream(new FileInputStream (inFile));
File outFile = new File(jtfSave.ge tText().trim()) ;
out = new BufferedOutputS tream(new FileOutputStrea m(outFile));
long totalBytes = in.available();
jpb.setValue(0) ;
jpb.setMaximum( 100);
int r;
long readBytes=0;
byte[] b = new byte[10];
while((r = in.read(b,0,b.l ength)) != -1){
out.write(b,0,r );
readBytes += r;
currentValue = (int)(readBytes * 100 / totalBytes);
jpb.setValue(cu rrentValue);
}
}
catch(FileNotFo undException ex){
ex.printStackTr ace();
}
catch(IOExcepti on ex){
ex.printStackTr ace();
}
finally{
try{
if (in != null) in.close();
if (out != null) out.close();
}
catch(Exception ex){}
}
}
java.io.FileNot FoundException: C:\Documents and Settings\XXXXXX X\My Documents (Access is denied)
at java.io.FileOut putStream.open( Native Method)
at java.io.FileOut putStream.<init >(FileOutputStr eam.java:179)
at java.io.FileOut putStream.<init >(FileOutputStr eam.java:131)
at test1.PilihFail $Salin2.run(Pil ihFail.java:111 )
the code is:
private int currentValue;
public void run(){
BufferedInputSt ream in = null;
BufferedOutputS tream out = null;
try{
File inFile = new File(jtfOpen.ge tText().trim()) ;
in = new BufferedInputSt ream(new FileInputStream (inFile));
File outFile = new File(jtfSave.ge tText().trim()) ;
out = new BufferedOutputS tream(new FileOutputStrea m(outFile));
long totalBytes = in.available();
jpb.setValue(0) ;
jpb.setMaximum( 100);
int r;
long readBytes=0;
byte[] b = new byte[10];
while((r = in.read(b,0,b.l ength)) != -1){
out.write(b,0,r );
readBytes += r;
currentValue = (int)(readBytes * 100 / totalBytes);
jpb.setValue(cu rrentValue);
}
}
catch(FileNotFo undException ex){
ex.printStackTr ace();
}
catch(IOExcepti on ex){
ex.printStackTr ace();
}
finally{
try{
if (in != null) in.close();
if (out != null) out.close();
}
catch(Exception ex){}
}
}
Comment