473,466 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

To input a character in Java

3 New Member
Hi There
Can anyone write me a program in which a character input is taken from console? If I am executing a program using do..while() loop. Is there any way through which I could clear the contente of console each time when execution takes place.

Thanks n Regards,
Shiv Kumar Singh
May 25 '07 #1
6 2147
r035198x
13,262 MVP
Hi There
Can anyone write me a program in which a character input is taken from console? If I am executing a program using do..while() loop. Is there any way through which I could clear the contente of console each time when execution takes place.

Thanks n Regards,
Shiv Kumar Singh
Write the code yourself. We are only here to help you write the code. Clearing the console is not something you want to do now in java. Your best bet is to write yourself a clrscr method which simply prints blank lines to the console until there's nothing showing.
May 25 '07 #2
shiv4singh
3 New Member
Well I wrote the code and used read() method but it was generating IOException. Below is the code that I had coded :

import java.io.*;
import java.io.Reader;
public class test
{
public static void main() //throws Exception
{
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a Character :");
try
{
//char ch= (char)(System.in.read());
char ch = (char)(buf.read());
}
catch(IOException ei)
{
System.out.println("Error");
}
}
}
May 25 '07 #3
r035198x
13,262 MVP
Use Scanner for taking input. There's a thread in this forum now that's discussing that.
May 25 '07 #4
JosAH
11,448 Recognized Expert MVP
Instead of just printing "Error" do this: "e.printStackTrace()" and see the reason
for that ugly exception in all its glory.

kind regards,

Jos
May 25 '07 #5
akash banasha
1 New Member
what ever u hav writtn is mere bullshit ......... stop giving nymore reply
Jun 16 '07 #6
JosAH
11,448 Recognized Expert MVP
what ever u hav writtn is mere bullshit ......... stop giving nymore reply
Pardon me, but I haven't seen any 'mere bullshit' in this thread until you replied.
The OP is learning and s/he has been given some advice. Everyone is free to
reply in any public thread, you can't make them stop nor can you forbid such
actions. please refrain from such replies in the near future; thanks.

kind regards,

Jos
Jun 16 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I...
30
by: Richard | last post by:
Level: Java newbie, C experienced Platform: Linux and Win32, Intel Another programmer and I are working on a small project together. He's writing a server process in Java that accepts input...
8
by: Luke Matuszewski | last post by:
Hi ! I have faced the problem of checking that the user has entered the unicode letter (not only ASCII set of letters...). It seems that ECMAScript 3rd regular expressions do not include posix...
3
by: javaBookWorm | last post by:
import java.applet.Applet; import java.awt.*; // Contains all of the classes for creating user interfaces and for painting graphics and images. import java.awt.event.*;//The root event class for...
11
by: arnuld | last post by:
C takes input character by character. I did not find any Standard Library function that can take a word as input. So I want to write one of my own to be used with "Self Referential Structures" of...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.