/* * ReadFile2.java * * Created on January 10, 2011, 4:55 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package file; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; /** * * @author ocamposm */ public class ReadFile2 { /** Creates a new instance of ReadFile2 */ public ReadFile2() { } public static void main(String args[]) throws IOException { String thisLine; String[] fullText = new String[10]; int counter =0; FileInputStream fis = new FileInputStream("sample.txt"); DataInputStream myInput = new DataInputStream(fis); while ((thisLine=myInput.readLine())!= null) { System.out.println(thisLine); counter++; fullText[counter]=thisLine; } } }