Advertisement
Guest User

Processing

a guest
Apr 12th, 2012
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4.  
  5. public class Processing
  6. {
  7.    
  8.     public static List<Program> readAllData() {
  9.            
  10.            List<Program> schedule = new LinkedList<Program>();
  11.  
  12.         try{
  13.             FileInputStream fstream = new FileInputStream("file.txt");
  14.  
  15.             DataInputStream in = new DataInputStream(fstream);
  16.             BufferedReader br = new BufferedReader(new InputStreamReader(in));
  17.             String tempString = null;
  18.  
  19.  
  20.             while ((tempString = br.readLine()) != null)   {
  21.  
  22.  
  23.                 String[] row = tempString.split("-");
  24.  
  25.                 if(row[0].compareTo("COMEDY") == 0) {
  26.  
  27.                     Comedy comedy = new Comedy(row[0], row[1], Integer.parseInt(row[2]), row[3], row[4], Boolean.parseBoolean(row[5]), row[6]);
  28.                     schedule.add(comedy);
  29.  
  30.                 }
  31.  
  32.                 else if(row[0].compareTo("DRAMA") == 0) {
  33.  
  34.                     Drama drama = new Drama(row[0], row[1], Integer.parseInt(row[2]), row[3], row[4], Boolean.parseBoolean(row[5]), row[6]);
  35.                     schedule.add(drama);
  36.  
  37.                 }
  38.  
  39.                 else if(row[0].compareTo("MUSIC") == 0) {
  40.  
  41.                     MusicVideo music = new MusicVideo(row[0], row[1], Integer.parseInt(row[2]));
  42.                     schedule.add(music);
  43.  
  44.                 }
  45.  
  46.                 else if(row[0].compareTo("HOTEL") == 0) {
  47.  
  48.                     HotelInfo hotel = new HotelInfo(row[0], row[1], Integer.parseInt(row[2]));
  49.                     schedule.add(hotel);
  50.  
  51.                 }
  52.  
  53.             }
  54.             in.close();
  55.  
  56.         }
  57.  
  58.         catch (Exception e){
  59.             System.err.println("Error: " + e.getMessage());
  60.         }
  61.                
  62.                
  63.     return schedule;
  64.     }
  65.  
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement