import java.io.File;
import java.io.FileInputStream;
public class Test
{
String s="";
int i;
try
{
File file = new File("c:\demo.txt");
FileInputStream in = FileInputStream(file);
while(i=in.read()!=-1)
{
s=s+(char)i;
}
in.close();
}
catch(Exception e)
{
s="文件找不到";
}
System.out.println(s);
}
//以上的代码运行结果老是出现乱码,是怎么回事儿呀?
|