import java.io.*;public class Example10
{
public static void main(String[] args)
{
try
{
File f = new File("file1.txt");
FileInputStream fis1=new FileInputStream(f);
int i;
while((i=fis1.read())!=-1)
{
System.out.print(i);
}
fis1.close();
}
catch(IOException e)
{
System.out.println("文件没有发现");
}
}
}我的文件中数据是0123456789abcdefg 我想在屏幕中显示的也是这个
但执行显示的是48495051525354555657979899100101102103,是每个字符的码值,
如何转换,能实现在屏幕中显示0123456789abcdefg
{
public static void main(String[] args)
{
try
{
File f = new File("file1.txt");
FileInputStream fis1=new FileInputStream(f);
int i;
while((i=fis1.read())!=-1)
{
System.out.print(i);
}
fis1.close();
}
catch(IOException e)
{
System.out.println("文件没有发现");
}
}
}我的文件中数据是0123456789abcdefg 我想在屏幕中显示的也是这个
但执行显示的是48495051525354555657979899100101102103,是每个字符的码值,
如何转换,能实现在屏幕中显示0123456789abcdefg
BufferedReader input = new BufferedReader(fis1);
input.read();
try {
File f = new File("e:\\file1.txt");
BufferedReader isr = new BufferedReader(new FileReader(f));
int i;
while (true) {
String lineStr = isr.readLine();
if(lineStr==null)
break;
System.out.println(lineStr);
}
isr.close();
} catch (IOException e) {
System.out.println("文件没有发现");
} }
1.输出转化为Char型的
2.BufferedReader每次读一行写一行,就不会有问题了