public class FileIO {
public static void main(String[] args){
ArrayList list = loadFile(args[0]);
for(int i=0;i System.out.println(i+1+":t"+list.get(i));
}
public static ArrayList loadFile(String fileName){
if(fileName==null||fileName==""){
throw new IllegalArgumentException();
}
String line;
ArrayList file = new ArrayList();
try{
BufferedReader br = new BufferedReader(new FileReader(fileName));
if(!br.ready())
throw new IOException();
while((line=br.readLine())!=null)
file.add(line);
br.close();
}catch(IOException e){
System.out.println(e);
return null;
}
return file;
}
}
转自:http://www.computing.net/programming/wwwboard/forum/12276.html
[@more@]来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7911270/viewspace-914258/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7911270/viewspace-914258/