|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteos.util.In
public class In
Input. This class provides methods for reading strings and numbers from standard input, file input, URL, and socket.
The Locale used is: language = English, country = US. This is consistent with the formatting conventions with Java floating-point literals, command-line arguments (via Double.parseDouble()) and standard output (via System.out.print()). It ensures that standard input works the number formatting used in the textbook.
For additional documentation, see Section 3.1 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.
Constructor Summary | |
---|---|
In()
Create an input stream for standard input. |
|
In(java.io.File file)
Create an input stream from a file. |
|
In(java.net.Socket socket)
Create an input stream from a socket. |
|
In(java.lang.String s)
Create an input stream from a filename or web page name. |
|
In(java.net.URL url)
Create an input stream from a URL. |
Method Summary | |
---|---|
void |
close()
Close the input stream. |
boolean |
exists()
Does the input stream exist? |
boolean |
hasNextLine()
Does the input stream have a next line? |
boolean |
isEmpty()
Is the input stream empty? |
static void |
main(java.lang.String[] args)
Test client. |
java.lang.String |
readAll()
Read and return the remainder of the input as a string. |
boolean |
readBoolean()
Return the next boolean from the input stream, allowing "true" or "1" for true and "false" or "0" for false. |
byte |
readByte()
Return the next byte from the input stream. |
char |
readChar()
Read and return the next character. |
double |
readDouble()
Return the next double from the input stream. |
double |
readFloat()
Return the next float from the input stream. |
int |
readInt()
Return the next int from the input stream. |
java.lang.String |
readLine()
Read and return the next line. |
long |
readLong()
Return the next long from the input stream. |
java.lang.String |
readString()
Return the next string from the input stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public In()
public In(java.net.Socket socket)
public In(java.net.URL url)
public In(java.io.File file)
public In(java.lang.String s)
Method Detail |
---|
public boolean exists()
public boolean isEmpty()
public boolean hasNextLine()
public java.lang.String readLine()
public char readChar()
public java.lang.String readAll()
public java.lang.String readString()
public int readInt()
public double readDouble()
public double readFloat()
public long readLong()
public byte readByte()
public boolean readBoolean()
public void close()
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |