Read a textfile into an ArrayList
512 viewsJAVA:
-
/*--------------------------------------------------------------------------
-
ScanToArrayDemo class
-
*****************
-
By: HappyFace http://www.engineeringserver.com
-
Contact: info [@] engineeringserver.com
-
Version: 10/September/2008
-
"*****************
-
Note: Read a textfile into an ArrayList
-
//----------------------------------------------------------------------*/
-
import java.io.File;
-
import java.io.FileNotFoundException;
-
import java.io.IOException;
-
import java.util.ArrayList;
-
import java.util.Scanner;
-
-
public class ScanToArrayDemo {
-
String tmp = "";
-
try {
-
Scanner scInput = new Scanner(fInput);
-
while (scInput.hasNextLine()){
-
tmp = scInput.nextLine();
-
textHolder.add(tmp);
-
}
-
}
-
e.printStackTrace();
-
}
-
e.printStackTrace();
-
}
-
//display the content of the array
-
}
-
}












