It smells of homework. If you need to re-read your notes and tell us what you tried.
Personally, I would use a scanner (from java.util).
import java.io.*;
import java.util.*;
public class Franky {
public static void main(String[] args) {
Scanner sc = new Scanner(new File("myfile.txt"));
String[] items = new String[3];
int i = 0;
while(sc.hasNextLine() && i < items.length) {
items[i] = sc.nextLine();
i++;
}
}
}
source
share