File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Generics IO using input from console Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Generics IO using input from console" Watch "Generics IO using input from console" New topic

Generics IO using input from console

Marcus Johnson

Joined: Dec 27, 2011
Posts: 1

//I can make an interface and a javabean with getters and setters, but with the code below not able to get movie out to console after entering director name.

import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

import java.sql.Connection;
import java.util.Enumeration;

public class ChosenDirector {

//Create a buffered reader to read
//each line from the keyboard.

static ArrayList<String> chosendirector=new ArrayList<String>();

public static void main(String args[]) throws IOException {
InputStreamReader ir = new InputStreamReader(;
BufferedReader in = new BufferedReader(ir);
String director=" "; // Note: here we are assuming Director could
String movie= " "; // or will be different for each user.
String FILE_NAME = "Directormovies.txt";
String s;
// read the DIRECTOR information from the console, and
//when director name is entered his movie should come from FILE_NAME Wild at Heart, The Muppets, Jurassic Park, Batman, and RockyVI
System.out.println ("Enter Director name to get Movie : David Lynch, Jim Henson, Stephen Spielberg, Tim Burton or, Aki Kaurismaki");

//StringBuffer stdin = StringBuffer;{

System.out.print("NAME OF DIRECTOR: \n" );
s = in.readLine();
try {

} catch (SecurityException se) {

// read the Director and Movie information from the file
//System.out.println("About to read Director info from file "
// + FILE_NAME);
File srcFile = new File(FILE_NAME);

//print out the Director name and his movie
File c = srcFile;

for(String c1: chosendirector)
String[] temp = c1.split(":");
//now we should have temp[0] = "director" and temp[1] = "movie"

while (director.split(movie)!=null) {
String[] tokens = director.split("[:]+");

System.out.println("Name of Director is: "+ director + "and movie is:"+ movie);



I agree. Here's the link:
subject: Generics IO using input from console