Java Reference
In-Depth Information
public final void writeLong( long n ) throws IOException
Writes the long n to the fi le.
public final void writeShort( short n ) throws IOException
Writes the short n to the fi le.
public final void writeUTF(String s ) throws IOException
Writes the String s to the fi le.
Scanner
Package: java.util
Ancestor classes:
Object
|
+--Scanner
The Scanner class can be used to obtain input from fi les as well as from the keyboard. Values to
be read should be separated by whitespace characters, such as blanks and/or new lines. When
reading values, these whitespace characters are skipped. (It is possible to change the separators
from whitespace to something else, but whitespace is the default.)
public Scanner(InputStream streamObject)
There is no constructor that accepts a fi le name as an argument. If you want to create a stream
using a fi le name, you can use
new Scanner( new FileInputStream( File_Name ))
When used in this way, the FileInputStream constructor, and thus the Scanner constructor
invocation, can throw a FileNotFoundException , which is a kind of IOException.
To create a stream connected to the keyboard, use
new Scanner(System.in)
public Scanner(File fileObject)
If you want to create a stream using a fi le name, you can use
new Scanner( new File( File_Name ))
public int nextInt()
Returns the next token as an int , provided the next token is a well-formed string representation
of an int .
Throws:
NoSuchElementException if there are no more tokens.
InputMismatchException if the next token is not a well-formed string representation of an int .
IllegalStateException if the Scanner stream is closed.
 
Search WWH ::




Custom Search