Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Processing
- {
- public static List<Program> readAllData() {
- List<Program> schedule = new LinkedList<Program>();
- try{
- FileInputStream fstream = new FileInputStream("file.txt");
- DataInputStream in = new DataInputStream(fstream);
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- String tempString = null;
- while ((tempString = br.readLine()) != null) {
- String[] row = tempString.split("-");
- if(row[0].compareTo("COMEDY") == 0) {
- Comedy comedy = new Comedy(row[0], row[1], Integer.parseInt(row[2]), row[3], row[4], Boolean.parseBoolean(row[5]));
- schedule.add(comedy);
- }
- else if(row[0].compareTo("DRAMA") == 0) {
- Drama drama = new Drama(row[0], row[1], Integer.parseInt(row[2]), row[3], row[4], Boolean.parseBoolean(row[5]));
- schedule.add(drama);
- }
- else if(row[0].compareTo("MUSIC") == 0) {
- MusicVideo music = new MusicVideo(row[0], row[1], Integer.parseInt(row[2]));
- schedule.add(music);
- }
- else if(row[0].compareTo("HOTEL") == 0) {
- HotelInfo hotel = new HotelInfo(row[0], row[1], Integer.parseInt(row[2]));
- schedule.add(hotel);
- }
- }
- in.close();
- }
- catch (Exception e){
- System.err.println("Error: " + e.getMessage());
- }
- return schedule;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement