Wednesday, November 4, 2009

Crossover Emulator For Mac Trade Pokemon

Reading data from the keyboard in Java (Third form) responds to events

In the previous post on reading data from the second form use a method that returns the text we put into a command prompt / terminal until you press the enter key , or which is equal to that System.in receive '\\ n' (line using the backslash caractetes). The data that we receive the added to a string that is returned upon completion with the reading method. One way to perform the above process is helping us with a read buffer. Buffer to be defined as the space in the memory of our computer that we can store a certain amount of information temporarily or until they are processed.

class from java.io BufferedReader is a class that allows us to read data in sequence, which gives us greater reliability in the reading done. By default, the buffer created BufferedReader is large enough to cover virtually any need, and also gives us the possibility to obtain the text from a file or other information flow.

To read data from our console have to wrap within BufferedReader data flow manipulate them in our case we will use the keyboard to the class to wrap InputStreamReader also java.io package , a bridge between the standard input buffer and Java, as InputStreamReader is a decoder bytes causes us these bytes in the corresponding character. So it is strongly recommended to use the buffer for reading data. However, suffice to specify where to get the InputStreamReader to convert bytes to characters.

Some methods of the class BufferedReader are void

close () - Close reading of data flow Void

mark (int anchor) - Mark the position in the data stream int

read () - Read a single character String

readLine ( ) - Read a line of text

ready boolean () - Decide if the flow is ready to be read

void reset () - Restores flow to the brand
recent
Example:

{public class
Reading Public static void main (String args []) {
String name = "" , address = ", phone = " " ;
BufferedReader buffer = new BufferedReader ( new InputStreamReader (System.in));
System . out. Print ( Name: ")
name = buffer. readLine ();
System.out. print ( "Address:" )
address = buffer. readLine ();
System.out. print ( "Telefono: ")
phone = buffer. readLine ();
System.out. println ( "\\ nData enter: \\ n" + name + "\\ n" + address + "\\ n" + phone);
System. exit (0);

}}

0 comments:

Post a Comment