import java.io.*; import java.util.Scanner; public class ReadText1 { public static void main(String[] args) throws IOException { String[] a = new String[100]; // Create String array of 100 elem's int numWords; // Count # words in input File myFile = new File("inp1"); // Open file "inp1" Scanner in = new Scanner(myFile); // Make Scanner obj with opened file numWords = 0; while ( in.hasNext() ) { a[numWords] = in.next(); // Read next string (word) numWords++; // Count # words AND use next // array element for next word } System.out.println("Printing the array..."); for ( int i = 0; i < numWords; i++ ) System.out.println( a[i] ); } }