No character stream reads data garbled
byte stream data may be read because of the different character sets, each character corresponding to the character size different from
the garbled /
Read read = new FileReader (File f); or path
Operation:
In addition to selecting and changing the flow of the byte array into a character array, the other are the same
public class test{
public static void main(String[]args)
{
File f =new File("C:/Users/10853/eclipse-workspace/hell/src/hell/abc");
Reader reader=null;
try {
reader=new FileReader(f);
**char[] flush =new char[1024];**
int len=-1;
try {
while((**len=reader.read(flush))!=-1**)
{//字符数组-->字符串
**String s=new String(flush,0,len);**
System.out.println(s);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}catch(IOException e)
{
e.printStackTrace();
}finally {
try {
if(null!=reader)
{
reader.close();
}
}catch(IOException e)
{
e.printStackTrace();
}
}
}
}