🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #658

Re: Simple Java Input Help.

#658
From: Paul Murray
Date: Sun, 02 Jul 2000 00:00
29 lines
1735 bytes
"Myke" <myke@net2000.com.au> wrote in message
news:VGA55.50$7f7.4121@nsw.nnrp.telstra.net...

> All I want to do is ask a user for text input at the command line.

For that, you need to wrap a BufferedReader around System.in . Now system.in
reads raw bytes, not characters (remember, characters in java are 2-byte
unicode values), so you need to wrap system.in in a InputStreamReader first.
This means that if a person is in Japan and types in JIS keyboard escape
codes, the reader will correctly convert to japanese unicode characters.
Enter a period on a line by itself to exit the loop.

import java.io.*;

public class go {
 public static void main(String[] av) throws IOException {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

  String ln;
  do {
   ln = br.readLine();
   System.out.println(">>>" + ln + "<<<");
  } while(!".".equals(ln));
 }
}

--------------------------------------------------------------
http://www.users.bigpond.com/pmurray
ICQ: 26066755
Technical Details
Message-ID: <0A_75.5257$c5.13904@newsfeeds.bigpond.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <VGA55.50$7f7.4121@nsw.nnrp.telstra.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,20edaadabe63645e
X-Google-Attributes: gid10d6db,public
From: "Paul Murray" <pmurray@nospam.bigpond.com>
Subject: Re: Simple Java Input Help.
Date: 2000/07/02
Message-ID: <0A_75.5257$c5.13904@newsfeeds.bigpond.com>
X-Deja-AN: 641782165
References: <VGA55.50$7f7.4121@nsw.nnrp.telstra.net>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
X-Trace: newsfeeds.bigpond.com 962622844 139.134.124.192 (Mon, 03 Jul 2000 21:14:04 EST)
Organization: Telstra BigPond Internet Services (http://www.bigpond.com)
X-MSMail-Priority: Normal
NNTP-Posting-Date: Mon, 03 Jul 2000 21:14:04 EST
Newsgroups: aus.computers.java