How to detect line break while reading input ?

Hi all,

I am reading the user input from standard input.

I want to detect the line break. So that I can stop reading input and proceed processing the string.

Actually I am getting the SQL query as input and after that I am executing the same by passing it to a function.

Pl. do reply me.

Scanner scanner =new Scanner(System.in);

while(scanner.hasNext())

{

temp=scanner.next();

sql=sql.concat(" "+temp);

if(scanner.next=="\n")

break;

}

System.out.println(sql);

sqlTool.executeSQL(sql);

The above is not working properly.

[868 byte] By [dhillaruna] at [2007-11-27 3:20:50]
# 1
Scanner.next gives you the next line.
kajbja at 2007-7-12 8:23:34 > top of Java-index,Java Essentials,New To Java...
# 2
But if new line comes, what will be it's value?
dhillaruna at 2007-7-12 8:23:34 > top of Java-index,Java Essentials,New To Java...
# 3
> But if new line comes, what will be it's value?Empty lines are discarded by the scanner.Kaj
kajbja at 2007-7-12 8:23:34 > top of Java-index,Java Essentials,New To Java...
# 4
(You will get the empty lines if you use scanner.nextLine() instead)
kajbja at 2007-7-12 8:23:34 > top of Java-index,Java Essentials,New To Java...