This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics IO using input from console  RSS feed

Marcus Johnson
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

//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);



  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!