public final class In extends Object
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 and Description |
---|
In()
Create an input stream for standard input.
|
In(File file)
Create an input stream from a file.
|
In(Socket socket)
Create an input stream from a socket.
|
In(String s)
Create an input stream from a filename or web page name.
|
In(URL url)
Create an input stream from a URL.
|
Modifier and Type | Method and Description |
---|---|
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(String[] args)
Test client.
|
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.
|
static double[] |
readDoubles()
Read doubles from standard input
|
static double[] |
readDoubles(String filename)
Read doubles from file
|
double |
readFloat()
Return the next float from the input stream.
|
int |
readInt()
Return the next int from the input stream.
|
static int[] |
readInts()
Read ints from standard input
|
static int[] |
readInts(String filename)
Read ints from file
|
String |
readLine()
Read and return the next line.
|
long |
readLong()
Return the next long from the input stream.
|
String |
readString()
Return the next string from the input stream.
|
static String[] |
readStrings()
Read strings from standard input
|
static String[] |
readStrings(String filename)
Read strings from a file
|
public In()
public In(Socket socket)
public In(URL url)
public In(File file)
public In(String s)
public boolean exists()
public boolean isEmpty()
public boolean hasNextLine()
public String readLine()
public char readChar()
public String readAll()
public String readString()
public int readInt()
public double readDouble()
public double readFloat()
public long readLong()
public byte readByte()
public boolean readBoolean()
public static int[] readInts(String filename)
public static double[] readDoubles(String filename)
public static int[] readInts()
public static double[] readDoubles()
public static String[] readStrings()
public void close()
public static void main(String[] args)