/* * Cuts down the ratings file to a smaller size, to make debugging faster. * * @author Dave Musicant */ import java.io.*; import java.util.*; public class FewerRatings { public static void main(String[] args) throws IOException { Scanner in = new Scanner(new FileInputStream("ratings.dat")); // The ratings are delimited by a double colon within a line, or // by a "newline" at the end of a line in.useDelimiter("::|\\n"); // Want to read only the first 500 users; but also should be safe // and make sure haven't gone past the end of the file int userId = -1; int maxUserId = 500; while (in.hasNext() && userId <= maxUserId) { userId = in.nextInt(); int movieId = in.nextInt(); int rating = in.nextInt(); int time = in.nextInt(); if (userId <= maxUserId) { System.out.println(userId + "::" + movieId + "::" + rating + "::" + time); } } } }