I am attempting to print specific data from a dat file, in this case, this file holds data on multiple movies. How would I print the data of only the id
and title
column?
Contents of movie.dat file
id title imdbID SpanishTitle
1 Toy story 0114709 juguetes
2 Jumanji 0113497 jumanji
3 Grumpy Old Men 0107050 Dos viejos grunoes
4
My attempt in code
import java.io.*;
public class ReadFromFile2 {
public static void main(String[] args)throws Exception {
File file = new File("movies.dat");
BufferedReader br = new BufferedReader(new FileReader(file));
try {
String line;
while ((line = br.readLine()) != null){
String[] var = line.split(" ");
System.out.println(line);
}
} finally {
br.close();
}
}
}