/**
* 使用InputStreamReader解决格式乱码!
*/
import java.io.*;
public class InputStreamReaderTest {
public static void main(String[] args) throws IOException {
FileInputStream file = new FileInputStream("E://d.txt");//首先,获取文件。
InputStreamReader isr = new InputStreamReader(file,"Unicode");//将读取文件的格式转换为文件的格式,
int temp;
while ((temp=isr.read())!=-1){//循环遍历
System.out.print((char)temp);//输出文件里的内容
}
isr.close();//关闭isr
file.close();//关闭file
}
}
使用InputStreamReader解决格式乱码
最新推荐文章于 2024-05-18 03:00:43 发布