Baca Keyboard

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package program;

/**
 *093510166
 * @author Untung Subagio
 */
import com.sun.org.apache.bcel.internal.generic.RETURN;
import java.io.*;
public class BacaKeyboard166 {

    public static String bacaString(){
    int karakter;
    String str="";
    boolean selesai=false;
    while(!selesai){
        try{
           karakter=System.in.read();
           if(karakter<0 || (char)karakter=='\n')
               selesai=true;
           else if((char)karakter !='\n')
               str=str+(char)karakter;
        }catch(java.io.IOException e){
            System.out.println("ada kesalahan");
            selesai=true;
        }
        
        }
    return str;
    }
}

0 komentar:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | SharePoint Demo