找回密码
 注册

QQ登录

只需一步,快速开始

查看: 843|回复: 4
收起左侧

是知道java种下载的ConsoleIn class 要怎么用,我的一直就用不了

[复制链接]

该用户从未签到

发表于 2004-8-12 22:58 | 显示全部楼层 |阅读模式
我下了这东西,但是就一直不知道怎么弄,要放在同一个目录文件下面,但是我就是不知道怎么弄,谁知道请告诉我,尽量讲详细点,谢谢。我都弄了好久了,就是不行,悲哀。
  • TA的每日心情
    开心
    2023-4-15 08:35
  • 签到天数: 462 天

    连续签到: 1 天

    [LV.9]以坛为家II

    发表于 2004-8-12 23:04 | 显示全部楼层

    是知道java种下载的ConsoleIn class 要怎么用,我的一直就用不了

    java种下载的ConsoleIn class?什么东东?没有见过,哪里下载?
    回复 支持 反对

    使用道具 举报

    该用户从未签到

     楼主| 发表于 2004-8-12 23:09 | 显示全部楼层

    是知道java种下载的ConsoleIn class 要怎么用,我的一直就用不了

    java中不时有一个system.input吗?但是这个input比哪个好用一些,是一个独立的东西,下了但是不知道怎么用,有什么人能帮忙吗? 感激不尽。
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2023-4-15 08:35
  • 签到天数: 462 天

    连续签到: 1 天

    [LV.9]以坛为家II

    发表于 2004-8-12 23:20 | 显示全部楼层

    是知道java种下载的ConsoleIn class 要怎么用,我的一直就用不了

    你把下载地址给我。java我知道的不是很多。
    回复 支持 反对

    使用道具 举报

    该用户从未签到

     楼主| 发表于 2004-8-13 00:08 | 显示全部楼层

    是知道java种下载的ConsoleIn class 要怎么用,我的一直就用不了

    [这个贴子最后由前人旧梦在 2004/08/13 00:22am 第 1 次编辑]

    内容如下:
    其中有一段话是这样的: To use the ConsoleIn class for console input, we need to have the ConsoleIn class saved into the same directory of our Java programs. The ConsoleIn class should be compiled as well.
    不知道与它放到一起的程序是什么意思? 是我自己写的吧? 我好像放到一起了,是在同一个目录下。但是就是不行。什么原因?希望讲清楚一点。

    import java.util.*;
    import java.io.*;
    public final class ConsoleIn {
    private static BufferedReader brStream =
    new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer getTokenizer() throws IOException {
    return new StringTokenizer(brStream.readLine());
    }
    /* Reads a line of text and returns the line as boolean*/
    public static boolean readlnBoolean() {
    String stringToken = null;
    boolean ok = true;
    boolean result = false;
    while (ok){
    try {
    stringToken = getTokenizer().nextToken();
    if (stringToken.equalsIgnoreCase("true"))
    result = true;
    else if(stringToken.equalsIgnoreCase("false"))
    result = false;
    ok = false;
    }
    catch (IOException e) {
    System.out.println("Invalid Input!");
    System.out.print("lease enter the data again: ");
    }
    }
    return result;
    }
    /* Reads a line of text and returns the line as character*/
    public static char readlnChar() {
    String str = " ";
    boolean ok = true;
    char result = ' ';
    while (ok) {
    try {
    str = brStream.readLine(); // read the whole line.
    if (str.length() == 1) {
    result = str.charAt(0);
    ok = false;
    }
    }
    catch (IOException e) {
    System.out.println("Invalid Input!");
    System.out.print("lease enter the data again: ");
    }
    }
    return result;
    }
    /* Reads a line of text and returns the line as byte*/
    public static byte readlnByte() {
    String stringToken = null;
    boolean ok = true;
    byte result = 0;
    while (ok) {
    try {
    stringToken = getTokenizer().nextToken();
    result = Byte.parseByte(stringToken);
    ok = false;
    }
    catch (IOException e) {
    System.out.println("Invalid Input!");
    System.out.print("lease enter the data again: ");
    }
    }
    return result;
    }
    /* Reads a line of text and returns the line as short*/
    public static short readlnShort() {
    String stringToken = null;
    boolean ok = true;
    short result = 0;
    while (ok) {
    try {
    stringToken = getTokenizer().nextToken();
    result = Short.parseShort(stringToken);
    ok = false;
    }
    catch (IOException e) {
    System.out.println("Invalid Input!");
    System.out.print("Please enter the data again: ");
    }
    }
    return result;
    }
    /* Reads a line of text and returns the line as integer*/
    public static int readlnInt() {
    String stringToken = null;
    boolean ok = true;
    int result = 0;
    while (ok) {
    try {
    stringToken = getTokenizer().nextToken();
    result = Integer.parseInt(stringToken);
    ok = false;
    }
    catch (IOException e) {
    System.out.println("Invalid Input!");
    System.out.print("Please enter the data again: ");
    }
    }
    return result;
    }
    /* Reads a line of text and returns the line as long*/
    public static long readlnLong() {
    String stringToken = null;
    boolean ok = true;
    long result = 0;
    while (ok) {
    try {
    stringToken = getTokenizer().nextToken();
    result = Long.parseLong(stringToken);
    ok = false;
    }
    catch (IOException e) {
    System.out.println("Invalid Input!");
    System.out.print("Please enter the data again: ");
    }
    }
    return result;
    }
    /* Reads a line of text and returns the line as float*/
    public static float readlnFloat() {
    String stringToken = null;
    boolean ok = true;
    float result = 0;
    while (ok) {
    try {
    stringToken = getTokenizer().nextToken();
    result = Float.parseFloat(stringToken);
    ok = false;
    }
    catch (IOException e) {
    System.out.println("Invalid Input!");
    System.out.print("Please enter the data again: ");
    }
    }
    return result;
    }
    /* Reads a line of text and returns the line as double*/
    public static double readlnDouble() {
    String stringToken = null;
    boolean ok = true;
    double result =0;
    while (ok) {
    try {
    stringToken = getTokenizer().nextToken();
    result = Double.parseDouble(stringToken);
    ok = false;
    }
    catch (IOException e) {
    System.out.println("Invalid Input!");
    System.out.print("Please enter the data again: ");
    }
    }
    return result;
    }
    /* Reads a line of text and returns the line as string*/
    public static String readlnString() {
    boolean ok = true;
    String result = " ";
    while (ok) {
    try {
    result = brStream.readLine();
    ok = false;
    }
    catch (IOException e) {
    System.out.println("Invalid Input!");
    System.out.print("Please enter the data again: ");
    }
    }
    return result;
    }

    /* Reads the character value and catches the exception when
    it is not a character value*/
    public static char readChar() {
    int aChar = -1;
    try {
    aChar = System.in.read();
    }
    catch (IOException e) {
    System.out.println(e.getMessage());
    System.out.println("Invalid Input!");
    System.out.println("Program Terminating!");
    System.exit(0);
    }
    return (char) aChar;
    }
    /* Reads the string input and discard the whitespace.
    It will wait until it gets a non-whitecharacter*/
    public static String readString(){
    String aString = "";
    char aChar;
    aChar = readChar();
    while (Character.isWhitespace(aChar)) {
    aChar = readChar();
    }
    while (!(Character.isWhitespace(aChar))) {
    aString = aString + aChar;
    aChar = readChar();
    }
    if (aChar == '\r') {
    aChar = readChar();
    if (aChar != '\n') {
    System.out.println("Invalid Input!");
    System.out.println("Program Terminating!");
    System.exit(1);
    }
    }
    return aString;
    }
    /* Reads the integer value and catches the exception when
    it is not a integer value*/
    public static int readInt() {
    String aString = " ";
    int result = 0;
    try {
    aString = readString();
    aString = aString.trim();
    result = Integer.parseInt(aString);
    }
    catch (NumberFormatException e) {
    System.out.println("Invalid Input!");
    System.out.println("Program Terminating!");
    System.exit(0);
    }
    return result;
    }
    /* Reads the float value and catches the exception when
    it is not a float value*/
    public static float readFloat() {
    String aString = " ";
    float result= 0;
    try {
    aString = readString();
    aString = aString.trim();
    result = Float.parseFloat(aString);
    }
    catch (NumberFormatException e) {
    System.out.println("Invalid Input!");
    System.out.println("Program Terminating!");
    System.exit(0);
    }
    return result;
    }
    /* Reads the double value and catches the exception when
    it is not a double value*/
    public static double readDouble() {
    String aString = " ";
    double result = 0;
    try {
    aString = readString();
    aString = aString.trim();
    result = Double.parseDouble(aString);
    }
    catch (NumberFormatException e) {
    System.out.println("Invalid Input!");
    System.out.println("Program Terminating!");
    System.exit(0);
    }
    return result;
    }
    /* Reads the long value and catches the exception when
    it is not a long value*/
    public static long readLong() {
    String aString = " ";
    long result = 0;
    try {
    aString = readString();
    aString = aString.trim();
    result = Long.parseLong(aString);
    }
    catch (NumberFormatException e) {
    System.out.println("Invalid Input!");
    System.out.println("Program Terminating!");
    System.exit(0);
    }
    return result;
    }
    /* Reads the short value and catches the exception when
    it is not a short value*/
    public static short readShort() {
    String aString = " ";
    short result = 0;
    try {
    aString = readString();
    aString = aString.trim();
    result = Short.parseShort(aString);
    }
    catch (NumberFormatException e) {
    System.out.println("Invalid Input!");
    System.out.println("Program Terminating!");
    System.exit(0);
    }
    return result;
    }
    /* Reads the byte value and catches the exception when
    it is not a byte value*/
    public static byte readByte() {
    String aString = " ";
    byte result = 0;
    try {
    aString = readString();
    aString = aString.trim();
    result = Byte.parseByte(aString);
    }
    catch (NumberFormatException e) {
    System.out.println("Invalid Input!");
    System.out.println("Program Terminating!");
    System.exit(0);
    }
    return result;
    }
    /* Reads the boolean value and catches the exception when
    it is not a boolean value*/
    public static boolean readBoolean() {
    String aString = " ";
    boolean ok = true;
    boolean result = false;
    aString = readString();
    aString = aString.trim();
    if (aString.equalsIgnoreCase("true"))
    result = true;
    else if(aString.equalsIgnoreCase("false"))
    result = false;
    ok = false;
    return result;
    }
    }
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    QQ|小黑屋|《唐诗宋词》网站 ( 苏ICP备2021032776号 )

    GMT+8, 2024-11-16 18:30 , Processed in 0.078839 second(s), 18 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表