1 , Try {
The default current directory for Eclipse is the project root, and the relative path used in new File () should be the path to the relative root directory
FileInputStream input=new FileInputStream (New File ("Bin\\cn\\google\\demo\\data.txt"));
Byte[] B=new byte[100];
int Len=input.read (b);
Solve garbled problems
Method One: Manually construct string decoding
String Str=new string (B,0,len, "UTF-8");
System.out.println (str);
Method Two: Convert the byte stream to the corresponding coded character stream using the InputStreamReader object
FileInputStream input=New fileinputstream (new File ("Bin\\cn\\google\\demo\\data.txt"));
BufferedReader reader=New BufferedReader (new inputstreamreader(input, "UTF-8"));
int A;
while ((A=reader.read ())!=-1) {
System. out. Print ((char) a);
}
} catch (FileNotFoundException e) {
E.printstacktrace ();
}
2, System.out and system.in are coded output and input according to the platform's default code table, using the new string (...) to set the Code table in the parameters can be decoded, using the String's GetBytes (...) method to encode characters.
3. The properties of the project in Eclipse are encoded only by the Code table in the eclipse environment, that is, simply changing the encoding of system.in and System.out
Java File Encoding issues