我正在研究netbeans...我需要读取一个文件并进行标记,然后将其存储在一个数组中以供我将来的操作使用...我已经附加了第5行包含标记的代码...同时转换为数组iam得到错误为
例外 :
" Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1000
at preprocess.mainpage.jButton2ActionPerformed(mainpage.java:224)
at preprocess.mainpage.access$100(mainpage.java:18)
at preprocess.mainpage$2.actionPerformed(mainpage.java:62)"
代码:
int counter=-1;
int n=0;
String[] arr = new String[1000];
try
{
BufferedReader b = new BufferedReader(new FileReader("C:/Users/sky/Documents/NetBeansProjects/Preprocess/src/preprocess/cdr1.txt"));
String line;
while ((line = b.readLine()) != null)
{
counter+=1;
StringTokenizer st2 = new StringTokenizer(line, " ");
String line5 = (String) st2.nextElement();
arr[n] = line5;
n++;
}
}
catch (Exception e)
{
}