readline Error 2 1 Answer(s) 3 years and 2 months ago
Posted in : Java Beginners
Hi sir, can you look again please. The error is hard to notice, but if you execute the code, 1. enter a string the first input request (eg hello world), 2. ENTER
3a. ENTER n for the next input request The code will not terminated after the 'n'. This is because the first char is missing and from the readLine(). You would have to to enter 'nn' for the code to exit. I think the problem is caused by the read() statement, just don't know why.
3b. ENTER another string for the next input request (eg bye world) The code will output text "ye world", again the first char (b) is missing.
Could you please check again. I have to use the System.in.read() for this home work.
Thanks for the quick response thanks sella
View Answers
April 27, 2010 at 5:21 PM
Hi Friend,
Use br.readLine instead of System.in.read, your code will work.
Your modified code:
import java.io.*; class TestAdvt{ public static void main (String[] args){ boolean done=false; while (!done){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = null; try{ System.out.println ("Please enter the advertisement message to be displayed (enter 'n' to exit)"); str = br.readLine(); if (!str.equalsIgnoreCase("n")){ System.out.println ("str1 = " + str); Thread advt = new Thread(new Advertisement(str)); advt.start(); br.readLine(); advt.interrupt(); } else{ System.out.println ("str2 = " + str); done = true; } } catch (IOException e){ System.out.println("IOException caught: " + e.getMessage()); } } } } class Advertisement extends Thread{ private String message; Advertisement (String message) { this.message=message;} public void run(){ while (!message.equals("")){ try{ System.out.print(message+".. "); Thread.sleep(1000); } catch (InterruptedException e){ this.message=""; break; } } } }
Thanks
Related Pages:
readline Error 2 - Java Beginners readlineError2 Hi sir,
can you look again please.
The error... request (eg hello world),
2. ENTER
3a. ENTER n for the next input request... is missing and from the readLine(). You would have to to enter 'nn'
for the code
readline Error - Java Beginners readline Error Hi sir, please helpme with my code.
Mycode does not work. The readLine () method seems to loose the first character of the string...; Hi Friend,
Your code works fine here.
Thanks The error
Struts 2 File Upload error
Struts 2 File Upload error Hi! I am trying implement a file upload using Struts 2, I use this article, but now the server response the error:
ognl.MethodFailedException: Method "setArquivo" failed for object
error
error whats the error..............
import java.util.Scanner...();
switch(a)
{ case 1:add();
break;
case 2:sub();
break....");
System.out.println("2 For Subtract.");
a=s.nextInt();
switch(a)
{ case
error
is"+sum);
}
}
this is my program i need to print the series (1+2/12)+(1+2
Struts 2 : Http Status Error 404 - Struts
Struts 2 : Http Status Error 404 Hi All,
I'm facing the below... error as shown below.
see below error for the details
code...
---------------------------------------------------------------------------
ERROR(404) : "The requested
new 2
new 2 <%@page import="java.util.ArrayList"%>
<%@page...;
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
sevelet
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
import java.io.IOException;
import java.io.PrintWriter;
import
struts 2 Application starting error - Struts
struts 2 Application starting error Hello Sir/Madam,
Recently i have installed tomcat 5.5.23 on my window machine with XP,
then i make an small application which i have attached with name Struts2Application, but after
HTTP Status 404 - /web/login/showLogin.action Error in Struts 2 - Struts
HTTP Status 404 - /web/login/showLogin.action Error in Struts 2 Hi...
Eclipse 3.4
Struts 2
Now my question is I am trying to implement the login... the doLogin action . when I click on the link I get the following error
type Status
Struts 2 RequiredFieldValidator - Struts
What is Struts 2 RequiredFieldValidator? Need an Example or Code What is Struts 2 RequiredFieldValidator? Need an Example or Code on Field Validation in Struts 2. Please follow the following instruction:1. index.jsp
GUI 2 - Java Beginners
GUI 2 How can I modify this code? Please give me a GUI Example.Thanks!! This can be done using KeyEvent in the following way... written...){ System.out.println("---error in validation---"+e); } }//end
Java error reading from file
Java error reading from file
Java error reading file are the common error occurred in java that when
the user encounter a corrupt file
BCMWLTRY.EXE error
BCMWLTRY.EXE error Yesterday I did system restore after it I am getting two problems. 1. showing an error
message An unhandled exception ('System.IO.FileNotFoundException') occurred in
BCMWLTRY.EXE[5292]. 2. It restored one
JFREE error
JFREE error hi.........
the code for making chart is: WHICH IS GIVING THE ERROR
import org.jfree.chart.*;
import org.jfree.data.category.... DefaultCategoryDataset();
dataset.setValue(2, "Marks", "Rahul");
dataset.setValue(7
Struts 2 Url Validator
Struts 2 Url Validator
The URLValidator of Struts 2 Framework checks whether
the String contained within..., it generates an error message.
The error message is supplied
between
compile error
program with Test.java and try to compile with javac test.java an error like
test.java :2 : class A is public ,should be declared in a file named A.java
Struts 2 Login Application
Struts 2 Login Application
Developing Struts 2 Login Application
In this section we are going to develop login application based on Struts 2
Framework. Our current login application
error at programming error at programming import javax.servlet.http.*;
import...!=rs.getString(1)||pass!=rs.getString(2))
{
out.println("<html><body>...==rs.getString(1)&&pass==rs.getString(2))
{out.println("<html><
error at programming error at programming import javax.servlet.http.*;
import...!=rs.getString(1)||pass!=rs.getString(2))
{
out.println("<html><body>...==rs.getString(1)&&pass==rs.getString(2))
{out.println("<html><
error at programming error at programming import javax.servlet.http.*;
import...!=rs.getString(1)||pass!=rs.getString(2))
{
out.println("<html><body>...==rs.getString(1)&&pass==rs.getString(2))
{out.println("<html><
error at programming error at programming import javax.servlet.http.*;
import...!=rs.getString(1)||pass!=rs.getString(2))
{
out.println("<html><body>...==rs.getString(1)&&pass==rs.getString(2))
{out.println("<html><
error at programming error at programming import javax.servlet.http.*;
import...!=rs.getString(1)||pass!=rs.getString(2))
{
out.println("<html><body>...==rs.getString(1)&&pass==rs.getString(2))
{out.println("<html><
error at programming error at programming import javax.servlet.http.*;
import...!=rs.getString(1)||pass!=rs.getString(2))
{
out.println("<html><body>...==rs.getString(1)&&pass==rs.getString(2))
{out.println("<html><
error at programming error at programming import javax.servlet.http.*;
import...!=rs.getString(1)||pass!=rs.getString(2))
{
out.println("<html><body>...==rs.getString(1)&&pass==rs.getString(2))
{out.println("<html><
error at programming error at programming import javax.servlet.http.*;
import...!=rs.getString(1)||pass!=rs.getString(2))
{
out.println("<html><body>...==rs.getString(1)&&pass==rs.getString(2))
{out.println("<html><
Struts 2 Redirect Action
Struts 2 Redirect Action
In this section, you will get familiar with struts 2 Redirect
action and learn to use it in the struts 2 application.
Redirect After Post:
This post
Java Programming: Chapter 2 Quiz
Quiz Questions
For Chapter 2
THIS PAGE CONTAINS A SAMPLE quiz on material from
Chapter 2 of this on-line
Java textbook. You should be able... an example to illustrate the difference between a
syntax error and a semantics error
error at programming error at programming <p>import javax.servlet.http.*;
import...;
<p>if(name!=rs.getString(1)||pass!=rs.getString(2))
{
out.println("<...==rs.getString(1)&&pass==rs.getString(2))
{out.println("<html><
Java error illegal start of type
Java error illegal start of type
The Java error illegal start of type....
2)Buffered Reader- This used to read a text from a input stream to provide
you
error come error come com.techi.bean.Employee cannot be cast to [Ljava.lang.Object;...
i display the data action to jsp using set list atribute on action...(rs.getString("email"));
}
}
catch(Exception e){}
return list;
}
}
2
Error - Struts
-----------------------
RoseIndia.Net Struts 2 Tutorial
RoseIndia.net Struts 2... to test the examples
Run Struts 2 Hello
Struts 2 MySQL
Struts 2 MySQL
In this section, You will learn to connect the MySQL
database with the struts 2 application...;<!-- Rose India Struts 2 Tutorials -->
 
Struts 2 double validator
Struts 2 double validator
The Double validator of Struts 2 Framework checks if
the given input is double or not. If the input is not double, it generates the
error message. Double
Struts 2 Login Form Example
Struts 2 Login Form Example tutorial - Learn how to develop Login form in Struts 2 though this video tutorial
In this video tutorial I will explain you how you can create Login form in
Struts 2 and validate the login action
Struts 2 Actions
Struts 2 Actions
In this section we will learn about Struts 2 Actions, which is a fundamental
concept in most of the web application frameworks. Struts 2 Action are the
important concept in Struts 2
Struts 2 Validation (Int Validator)
Struts 2 Validation (Int Validator)
Struts 2 Framework provides in-built validation
functions to validate user... 2 validation framework can be extended to develop
custom validation functions
Struts 2 Date Validator
Struts 2 Date Validator
The Date validator in the Struts 2 Framework checks
whether the supplied date lies... in the specified range, it generates an error message.
The error message is supplied
ERRor in executing DB program ERRor in executing DB program While executing following code an Error was generated.can any one help me for this.
LiveDB liveDBObj... = liveDBObj.getPreparedStatement(qry);
pstmt.setDouble(1,2.0);
pstmt.setString(2,"name1");
int i
Struts 2 RequiredString validator
. Then
the error message is displayed to user.
This example demonstrates how to use Struts 2...Struts 2 RequiredString validator
This section discusses RequiredString validator of Struts 2 framework
Programming Error - JSP-Servlet
hi" is written then in count box it must displayed 2 words then how to do i tried integer.parseInt but its giving error.
Please Reply me .
Thank you...(' ').length;
}
2)
Thanks
ClassNotFound error - JDBC
ClassNotFound error Wen i run d code in JdbcMysqlConnectionUrl.java it shows an exception....
Can i kno y is dat error comes???
Is i want 2 download anything else than mysql n jdk1.6....
Clarify ma doubt soon.... 
Java Programming: Chapter 2 Quiz Answers
Sample Quiz Answers
For Chapter 2
THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on
Chapter 2 of this on-line
Java textbook. Note... error and a semantics error.
Answer:
The syntax of a language is its
Javascript matrix error
Javascript matrix error This function blows up (without an error) whenever it is called
function valid(n){ //n is a number 0-9
if(board...);
board[2]=new Array(3);
The program at start fills board with all zeros. The valid
Error - Java Beginners
to hex.
Please have a look on the code. In jsp page I got errors.
Error No 1:Incompatible type found,java.lang.objectrequired,java.lang.string.
Error No 2:sval already defined in merged scriptlet
Error No 3:haval already defined
Struts 2 File Upload
Struts 2 File Upload
In this section you will learn how to write program in
Struts 2 to upload the file... in any directory on the server machine.
The Struts 2 FileUpload component can