import java.io.*;

public class ConsoleReader extends BufferedReader
{
	public ConsoleReader(Reader in) throws IOException
	{
		super(in);
	}

	public ConsoleReader(InputStream in) throws IOException
	{
		super(new InputStreamReader(in));
	}

	public int readInt() throws IOException
	{
		return Integer.parseInt(readLine().trim());
	}

	public String readString() throws IOException
	{
		return readLine().trim();
	}

	public char readChar() throws IOException
	{
		String line = readLine().trim();
		return line.charAt(0);
	}

	public double readDouble() throws IOException
	{
		Double d = new Double(readLine().trim());
		return d.doubleValue();
	}
}


import java.io.*;

public class ConsoleReaderTest
{
	public static void main(String args[])
	{
		int ivalue;
		double dvalue;
		char cvalue;
		String svalue;
	
		try
		{
			ConsoleReader in = new ConsoleReader(System.in);
			System.out.print("정수를 입력해주세요:");
			ivalue = in.readInt();
			System.out.println("value = " + ivalue);
			System.out.print("\n실수를 입력해주세요:");
			dvalue = in.readDouble();
			System.out.println("value = " + dvalue);
			System.out.print("\n문자를 입력해주세요:");
			cvalue = in.readChar();
			System.out.println("value = " + cvalue);
			System.out.print("\n문자열을 입력해주세요:");
			svalue = in.readString();
			System.out.println("value = " + svalue);
		}
		catch (Exception e)
		{
			System.out.println("타입에 맞지 않은 입력입니다.");
		}
	}
}

2007/11/21 10:28 2007/11/21 10:28

Trackback URL : http://mysilpir.net/trackback/280

Leave a comment

« Previous : 1 : ... 47 : 48 : 49 : 50 : 51 : 52 : 53 : 54 : 55 : ... 270 : Next »

블로그 이미지

일상의 이야기를 나누는 공간입니다.

- 실피

Calendar

    «   2009/01   »
            1 2 3
    4 5 6 7 8 9 10
    11 12 13 14 15 16 17
    18 19 20 21 22 23 24
    25 26 27 28 29 30 31

Total 157585 hit (Today 30, Yesterday 185)

Admin Write Post