wwangl is right.
The object fIn must be initiated before you can use it.
The object fIn must be initiated before you can use it.
解决方案 »
- 帮我看下程序 还是有关数组的。
- 海量邮件的检索,能不能用JAVA做,能的话各位大侠请给我建议
- 小弟正在用java做通信方面的(用SNMP),刚接触java,请问哪为高手大哥推荐参考书。
- 梦想,有多久没有了
- 新人,在写一个从1加到1000的小程序是遇到点问题,求指点
- 其中ex.printStackTrace(); 是跟踪信息用的,我想问的是他打印出的信息在什么地方可以看到阿。
- 请问Jbuild有中文版的吗?
- 各位,可否介绍个JAVA的网站来呢?
- 请问学习oracle8,还是学习oracle8i好呢?学习oracle应打下哪些基础.应看什么书?
- URL传入参数有中文,编码不统一问题。恳请大佬帮忙看看
- SCJP是不是答对71%才有证书?????
- applet被限制调用系统资源,那么applet打印问题该如何解决,高手进来讨论
fIn=new FileInputStream(fileName);
不是吗?
不过这里,你可以随意建立一个text.txt的文件,
在你面你可以输入字符,为什么不能正确显示阿?import java.io.*;public class java31{
public static void main(String [] args){
String fileName="text.txt";
byte outString[]=new byte[10];
String outToScreen=new String();
FileInputStream fileIn;
try{
fileIn=new FileInputStream(fileName);
if(fileIn.read(outString,0,outString.length)!=-1)
outToScreen=outString.toString();
System.out.println(outToScreen);
}
catch(FileNotFoundException e)
{
System.out.println("File"+fileName+"Not Found");
System.exit(-2);
}
catch(IOException e)
{
System.out.println("Error"+e);
System.exit(-4);
}
}
}
import java.io.*;public class test{
public static void main(String [] args){
String fileName="text.txt";
byte outString[]=new byte[10];
String outToScreen=new String(); FileInputStream fileIn;
try{
fileIn=new FileInputStream(fileName);
while(fileIn.read(outString,0,outString.length)!=-1){
outToScreen=new String(outString);
System.out.println(outToScreen);
}
}catch(FileNotFoundException e){
System.out.println("File"+fileName+"Not Found");
System.exit(-2);
}catch(IOException e){
System.out.println("Error"+e);
System.exit(-4);
}
}
}