Topic: 关于异常问题!ArrayIndexOutOfBoundsException |
Print this page |
1.关于异常问题!ArrayIndexOutOfBoundsException | Copy to clipboard |
Posted by: SophiaBaby Posted on: 2005-09-05 23:44 The 800 KB attachment is removed. Please don't use BMP file as attachment, GIF or JPEG are much smaller! In fact, copy-n-paste from the Command Prompt window should be much better! Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at ReadFiel.main(ReadFiel.java:5) 请尽量使用准确的文字描述作为标题 Original subject : 关于异常问题! 请大家看一下这个程序: import java.io.*; public class ReadFiel { public static void main(String[] args){ File file=new File(args[0]); try{ BufferedReader in=new BufferedReader(new FileReader(file)); String s; while((s=in.readLine())!=null){ System.out.println(s); } in.close(); }catch(FileNotFoundException e1){ System.err.println("File is not found:"+file); }catch(IOException e2){ e2.printStackTrace(); } } } 为什么执行会出问题呢? |
2.Re:关于异常问题! [Re: SophiaBaby] | Copy to clipboard |
Posted by: ken0719 Posted on: 2005-09-07 15:03 When you run this program, you should give a parameter. This String is a path of the file that you want to read. |
3.Re:关于异常问题! [Re: SophiaBaby] | Copy to clipboard |
Posted by: wddodo Posted on: 2005-09-09 16:38 没看到错误。 是你运行的有问题吧! |
4.Re:关于异常问题! [Re: SophiaBaby] | Copy to clipboard |
Posted by: 低和 Posted on: 2005-09-10 11:49 java ReadFiel filename |
5.Re:关于异常问题!ArrayIndexOutOfBoundsException [Re: SophiaBaby] | Copy to clipboard |
Posted by: ocean Posted on: 2005-09-13 17:06 你运行的时候,要用命令行!用 "java" 命令向程序传参数: java ReadFiel args 这里的“args“就是你程序里对应的args[]数组! args[0] 的值就是 "a"。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |