日期:2014-05-20 浏览次数:20890 次
package com.inAndOut; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.List; class ReadIN { private List<Integer> list = new ArrayList<Integer>();// 存放整数 public List<Integer> input() throws IOException { BufferedReader in = null; String str = null; try { in = new BufferedReader(new FileReader("./你好.xls")); } catch (FileNotFoundException e) { e.printStackTrace(); System.out.println("这是打开文件错误!"); } str = in.readLine();// 抛弃第一行 while ((str = in.readLine()) != null) { String[] str2 = str.trim().split("\\s+");//通过空格切分 // 程序运行时出现错误 主要错误 for (int i = 1; i < str2.length; i++) {// 从第二个单元格开始 list.add(Integer.parseInt(str2[i])); } } in.close(); return list; } } public class Yunxing{ public static void main(String[] args){ ReadIN ri=new ReadIN(); List<Integer> list = new ArrayList<Integer>(); list=ri.input(); System.out.println(list);//出现错误 } }