CodePudding user response:
Copy the picture is actually accomplished by input and output flow of file to the filein reading and writingWriting is byte or character,
You look at your code accept=fip. Read ()
Accept you as the int type, then you write is the subscript, each byte read not write section, so you copy pictures are damaged
Fip. Read () returns the subscript for each of the writing, you want to switch to byte array, can write bytes
Below is I wrote before, I use the character of stream, you have to do is replace chars with an array of bytes, you can refer to the
InputStreamReader isr=null;
Try {
//used by copyFile (" C: \ \ Users \ \ Administrator \ \ Desktop \ \ test TXT ", "C: \ \ Users \ \ Administrator \ \ Desktop \ \ test_copy TXT", false);
The File File=new File (" C: \ \ Users \ \ Administrator \ \ Desktop \ \ test TXT ");
Isr=new InputStreamReader (new FileInputStream (file), "utf-8");
Char [] chars=new char [1024].
While (isr) read (chars)!=1) {
System. The out. Println (new String (" GBK ", chars));
}
} the catch (Exception e) {
e.printStackTrace();
} the finally {
Try {
Isr. The close ();
} the catch (IOException e) {
e.printStackTrace();
}
}
CodePudding user response:
Why can I runCodePudding user response:
CodePudding user response:
No problem I copied this pictureCodePudding user response:
I am also the same problem you found the solution?