Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.io.File;
- import java.io.IOException;
- import java.text.DecimalFormat;
- import java.util.StringTokenizer;
- import java.util.ArrayList;
- public class MovieManager{
- public void genData() throws IOException
- {
- File f = new File("movies.txt");
- if (!f.exists())
- {
- System.out.println("File doesn't exist.");
- System.exit(0);
- }
- Scanner read = new Scanner(f);
- read.nextLine();
- StringTokenizer st;
- String [] tokens;
- ArrayList <Integer> earnings = new ArrayList <Integer> ();
- String line = "";
- String title = "";
- int value1 = 0;
- int value2 = 0;
- int value3 = 0;
- DecimalFormat df = new DecimalFormat("$#00,000,000.00");
- while (read.hasNext())
- {
- line = read.nextLine();
- st = new StringTokenizer(line, ",");
- tokens = line.split(",");
- title = tokens[0];
- value1 = Integer.parseInt(tokens[1]);
- value2 = Integer.parseInt(tokens[2]);
- value3 = Integer.parseInt(tokens[3]);
- System.out.println(value1 + " " + value2 + " " + value3);
- earnings.add(value1);
- earnings.add(value2);
- earnings.add(value3);
- Movie m = new Movie(name, earnings);
- }
- read.close();
- }
- /*
- public void printData() throws IOException
- {
- DecimalFormat df = new DecimalFormat("$#,##0.00");
- for (Movie m : movie)
- {
- System.out.println(m);
- System.out.println();
- }
- }
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement