자바 키보드 입력 데이터

/*
    readLine                 。
readLine    BufferedReader     。
      read      InputStream    。


     。
*/
import java.io.*;
class TransStreamDemo 
{
	public static void main(String[] args) throws IOException
	{
		/*
		//        
		InputStream in=System.in;
		//              ,     。InputStreamReader
		InputStreamReader isr=new InputStreamReader(in);
		//      ,               。  BufferedReader
		BufferedReader br=new BufferedReader(isr);
		*/
		
		//         :
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		OutputStream out=System.out;
		OutputStreamWriter osw=new OutputStreamWriter(out);
		BufferedWriter bw=new BufferedWriter(osw);


		String line=null;
		while((line=br.readLine())!=null)
		{
			if(line.equals("over"))
				break;
			//System.out.println(line.toUpperCase());
			bw.write(line.toUpperCase());
			bw.newLine();
			bw.flush();
			
		}

		bw.close();
	}
}
/*
        ,    
*/
import java.io.*;
class KeyInput 
{
	public static void main(String[] args) throws IOException
	{
		keyInput();
	}

	public static void keyInput() throws IOException
	{
		InputStream in=System.in;
		StringBuffer sb=new StringBuffer();
		while(true)
		{
			char ch=(char)in.read();
			if(ch=='\r')
				continue;
			if(ch=='
') { String str=sb.toString(); if(str.equals("over")) break; System.out.println(str.toUpperCase()); sb.delete(0,str.length());// } else sb.append(ch); } } }

좋은 웹페이지 즐겨찾기