input from command line

I am trying to ask user to input string using netbeansbeta version

but it doesn't prompt me to enter the string unless i press enter 2 -3 times

/**

*

* @author xyz

*/

publicclass Main{

publicstaticvoid main(String[] args){

//Scanner input = new Scanner( System.in );

try{

String s="";

System.out.print("enter name ");

while((s= (new BufferedReader(new InputStreamReader(System.in))).readLine())!=null){

System.out.println(s);

}

}catch(Exception ex){

ex.printStackTrace();

}

File file =new File("C:\\month.txt");

FileInputStream fis =null;

BufferedInputStream bis =null;

BufferedReader bufferedReader =null;

String record;

int recCount=0;

int p=0;

try{

fis =new FileInputStream(file);

// Here BufferedInputStream is added for fast reading.

bis =new BufferedInputStream(fis);

bufferedReader =new BufferedReader(new InputStreamReader(bis));

while((record=bufferedReader.readLine()) !=null){

p=record.indexOf("Company A");

if (p != -1){

recCount++;

//System.out.println(p);

System.out.println(record);

}

}

}catch(Exception e){

e.printStackTrace();

}finally{

if(bufferedReader !=null){

try{

bufferedReader.close();

}catch(Exception e){

e.printStackTrace();

}

}

}

}

}

[3432 byte] By [seemapa] at [2007-11-26 12:22:23]
# 1

> while((s= (new BufferedReader(new InputStreamReader(System.in))).readLine())!=null){

It might not be the whole problem, but for one thing do note that you are continually creating a new InputStreamReader and new BufferedReader object at each loop cycle instead of just once like you should instead.

warnerjaa at 2007-7-7 15:15:35 > top of Java-index,Archived Forums,Socket Programming...