This code illustrates I/O handling with Java
Source Code
package DICAss; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.*; /** * * @author Pranshu */ public class DICAss5_IOHandle { public static void main(String[] args){ String Str; BufferedReader BRObj = new BufferedReader (new InputStreamReader(System.in)); System.out.print("Give Input : "); try{ Str = BRObj.readLine(); System.out.println("Input was " + Str); } catch(Exception err){ System.out.println("Error : " + err); } } }
Why not use a scanner?
ReplyDelete