WEB 开发 开发语言 Java 技术 .Net 技术 数 据 库 硬件使用
图象媒体 Linux/Unix 移动平台 嵌入开发 Windows 专区 软件工程
Ajax 技术 | ASP | PHP | ASP.NET | C# | JSP | Access | Oracle | 网页设计 | Flash | 安全专题 | IIS | VC/MFC | Delphi | C/C++
 你的位置:首页 > Java 技术 > J2SE / 基础类

finally的神秘问题
[ 来源:ITWENKU 时间:2006-9-7 16:33:42 | 浏览:183人次 ]

byte abc[]=new byte[80];
FileOutputStream oFile;
try{
oFile=new FileOutputStream("d:\\temp.txt");
oFile.write(abc);
}catch(IOException e1){}
finally{
oFile.close();
}

报错:variable oFile might not have been initialized at line 63, column 7
咋整,同志们!


局部变量必须初始化;
FileOutputStream oFile=null;


public static void main(String[] args) {
// TODO Auto-generated method stub
byte abc[]=new byte[80];
FileOutputStream oFile=null;
try{
oFile=new FileOutputStream("d:\\temp.txt");
oFile.write(abc);
oFile.flush();
}catch(IOException e1){}
finally{
try{
oFile.close();
}catch(IOException e1){}
}

}


同意楼上想法,必须初始化.


static void f5 () throws IOException {
byte abc[]=new byte[80];
FileOutputStream oFile =new FileOutputStream("d:\\temp.txt");
oFile.write(abc);
oFile.close();


楼主会不会结帖??打击回帖积极性....

 相关文章
·关于SimpleDateFormat转换时间的问题
·帮忙看一下源代码提示为什么不能注册JDBC driver
·我晕,我按网上设置的环境不行,我自己乱设成了,但不知原因
·一个我解决不了的问题
·怎样在JSP中使用自己写的类
·如何把JDBC3个jar文件导入的工程

 最新更新
在java中有哪个方法可以解决下面的问题啊:如取得一个雇员编号,当雇员编号<10需要在前面补0
关于static变量的用法
请问如何设置eclipse是其使用sun的Java编译器,而不是它自己的,谢谢
todo的使用?
读取大图片总是不行高手执教
有个关于JAVA向上转型的问题
如何改变键盘的输入值
FileReader与FileWriter读写"*。txt"的问题
如何将一个txt文件,读取到一个String数组里面
跟抽象类有关的问题
客户端连接服务器的时候,能绑定自己的端口号吗?
请问从socket取得的InputStream的readLine()方法是不是自动阻塞的?
 版权所有:中国IT问库
copyright © 2006 www.itwenku.com all rights reserved.