Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.74 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import java.text.DecimalFormat;
  5. import java.util.StringTokenizer;
  6. import java.util.ArrayList;
  7.  
  8. public class MovieManager{
  9.      
  10.     public void genData() throws IOException
  11.     {
  12.         File f = new File("movies.txt");
  13.        
  14.         if (!f.exists())
  15.         {
  16.             System.out.println("File doesn't exist.");
  17.             System.exit(0);
  18.         }
  19.        
  20.         Scanner read = new Scanner(f);
  21.         read.nextLine();
  22.  
  23.         StringTokenizer st;
  24.         String [] tokens;
  25.         ArrayList <Integer> earnings = new ArrayList <Integer> ();
  26.        
  27.         String line = "";
  28.        
  29.         String title = "";
  30.         int value1 = 0;
  31.         int value2 = 0;
  32.         int value3 = 0;
  33.        
  34.         DecimalFormat df = new DecimalFormat("$#00,000,000.00");
  35.  
  36.         while (read.hasNext())
  37.         {
  38.             line = read.nextLine();
  39.             st = new StringTokenizer(line, ",");
  40.             tokens = line.split(",");
  41.             title = tokens[0];
  42.             value1 = Integer.parseInt(tokens[1]);
  43.             value2 = Integer.parseInt(tokens[2]);
  44.             value3 = Integer.parseInt(tokens[3]);
  45.             System.out.println(value1 + " " + value2 + " " + value3);
  46.             earnings.add(value1);
  47.             earnings.add(value2);
  48.             earnings.add(value3);
  49.             Movie m = new Movie(name, earnings);
  50.         }
  51.        
  52.         read.close();
  53.     }
  54. /*
  55.     public void printData() throws IOException
  56.     {
  57.         DecimalFormat df = new DecimalFormat("$#,##0.00");
  58.          
  59.         for (Movie m : movie)
  60.         {
  61.             System.out.println(m);
  62.             System.out.println();
  63.         }
  64.     }
  65. */
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement