Java Doc for Scanner.java in  » Apache-Harmony-Java-SE » java-package » java » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.Scanner

Scanner
final public class Scanner implements Iterator<String>(Code)
A parser that parses a text string of primitive types and strings with the help of regular expressions. It supports localized numbers and various radixes. The input is broken into tokens by the delimiter pattern, which is whitespace by default. The primitive types can be obtained via corresponding next* methods. If the token is not in a valid format, an InputMismatchException is thrown. For example: Scanner s = new Scanner("1A true"); System.out.println(s.nextInt(16)); System.out.println(s.nextBoolean()); The result: 26 true A scanner can also find or skip specific patterns with no regard to the delimiter. All these methods and the various next* and hasNext* methods may block. The Scanner class is not thread-safe.



Constructor Summary
public  Scanner(File src)
     Constructs a scanner that uses File as its input.
public  Scanner(File src, String charsetName)
     Constructs a scanner that uses File as its input.
public  Scanner(String src)
     Constructs a scanner that uses String as its input.
public  Scanner(InputStream src)
     Constructs a scanner that uses InputStream as its input.
public  Scanner(InputStream src, String charsetName)
     Constructs a scanner that uses InputStream as its input.
public  Scanner(Readable src)
     Constructs a scanner that uses Readable as its input.
public  Scanner(ReadableByteChannel src)
     Constructs a scanner that uses ReadableByteChannel as its input.
public  Scanner(ReadableByteChannel src, String charsetName)
     Constructs a scanner that uses ReadableByteChannel as its input.

Method Summary
public  voidclose()
     Closes the underlying input if the input implements Closeable.
public  Patterndelimiter()
     Returns the Pattern in use by this scanner.
public  StringfindInLine(Pattern pattern)
     Tries to find the pattern in input.
public  StringfindInLine(String pattern)
     Tries to find the pattern compiled from the specified string.
public  StringfindWithinHorizon(Pattern pattern, int horizon)
     Tries to find the pattern in input from current position to the specified horizon.
public  StringfindWithinHorizon(String pattern, int horizon)
     Tries to find the pattern in input from current position to the specified horizon.
public  booleanhasNext()
     Returns true if this scanner has one or more tokens remaining to parse.
public  booleanhasNext(Pattern pattern)
     Returns true if this scanner has one or more tokens remaining to parse and the next token matches the given pattern.
public  booleanhasNext(String pattern)
     Returns true if this scanner has one or more tokens remaining to parse and the next token matches a pattern compiled from the given string.
public  booleanhasNextBigDecimal()
     Returns true if this scanner's next token can be translated into a valid BigDecimal.
public  booleanhasNextBigInteger()
     Returns true if this scanner's next token can be translated into a valid BigInteger in the default radix.
public  booleanhasNextBigInteger(int radix)
     Returns true if this scanner's next token can be translated into a valid BigInteger in the specified radix.
public  booleanhasNextBoolean()
     Returns true if this scanner's next token can be translated into a valid boolean value.
public  booleanhasNextByte()
     Returns true if this scanner's next token can be translated into a valid byte value in the default radix.
public  booleanhasNextByte(int radix)
     Returns true if this scanner's next token can be translated into a valid byte value in the specified radix.
public  booleanhasNextDouble()
     Returns true if this scanner's next token can be translated into a valid double value.
public  booleanhasNextFloat()
     Returns true if this scanner's next token can be translated into a valid float value.
public  booleanhasNextInt()
     Returns true if this scanner's next token can be translated into a valid int value in the default radix.
public  booleanhasNextInt(int radix)
     Returns true if this scanner's next token can be translated into a valid int value in the specified radix.
public  booleanhasNextLine()
     Returns true if there is another line in the input.
public  booleanhasNextLong()
     Returns true if this scanner's next token can be translated into a valid long value in the default radix.
public  booleanhasNextLong(int radix)
     Returns true if this scanner's next token can be translated into a valid long value in the specified radix.
public  booleanhasNextShort()
     Returns true if this scanner's next token can be translated into a valid short value in the default radix.
public  booleanhasNextShort(int radix)
     Returns true if this scanner's next token can be translated into a valid short value in the specified radix.
public  IOExceptionioException()
     Returns the last IOException thrown when reading the underlying input.
public  Localelocale()
     Return the locale of this scanner.
public  MatchResultmatch()
     Returns the match result of this scanner's last match operation.This method throws IllegalStateException if no match operation has been performed, or if the last match was unsuccessful. The various nextXXX methods of Scanner provide a match result if they do not complete with throwing an exception.
public  Stringnext()
     Returns the next token.
public  Stringnext(Pattern pattern)
     Returns the next token if it matches the specified pattern.
public  Stringnext(String pattern)
     Returns the next token if it matches the specified pattern.
public  BigDecimalnextBigDecimal()
     Returns the next token as a BigDecimal.
public  BigIntegernextBigInteger()
     Returns the next token as a BigInteger.
public  BigIntegernextBigInteger(int radix)
     Returns the next token as a BigInteger with the specified radix.
public  booleannextBoolean()
     Returns the next token as a boolean.
public  bytenextByte()
     Returns the next token as a byte.
public  bytenextByte(int radix)
     Returns the next token as a byte with the specified radix.
public  doublenextDouble()
     Returns the next token as a double.
public  floatnextFloat()
     Returns the next token as a float.
public  intnextInt()
     Returns the next token as an int.
public  intnextInt(int radix)
     Returns the next token as an int with the specified radix.
public  StringnextLine()
     Returns the skipped input and advances the scanner to the beginning of the next line.
public  longnextLong()
     Returns the next token as a long.
public  longnextLong(int radix)
     Returns the next token as a long with the specified radix.
public  shortnextShort()
     Returns the next token as a short.
public  shortnextShort(int radix)
     Returns the next token as a short with the specified radix.
public  intradix()
     Return the radix of this scanner.
public  voidremove()
     Remove is not a supported operation on Scanner.
public  Scannerskip(Pattern pattern)
     Tries to use specified pattern to match input from the current position. The delimiter will be ignored.
public  Scannerskip(String pattern)
     Tries to use the specified string to construct a pattern.
public  StringtoString()
     Returns a string.
public  ScanneruseDelimiter(Pattern pattern)
    
public  ScanneruseDelimiter(String pattern)
    
public  ScanneruseLocale(Locale l)
     Set the locale of this scanner to a specified locale.
public  ScanneruseRadix(int radix)
     Set the radix of this scanner to the specified radix.


Constructor Detail
Scanner
public Scanner(File src) throws FileNotFoundException(Code)
Constructs a scanner that uses File as its input. The default charset is applied when reading the file.
Parameters:
  src - the file to be scanned
throws:
  FileNotFoundException - if the specified file is not found



Scanner
public Scanner(File src, String charsetName) throws FileNotFoundException(Code)
Constructs a scanner that uses File as its input. The specified charset is applied when reading the file.
Parameters:
  src - the file to be scanned
Parameters:
  charsetName - the name of the encoding type of the file
throws:
  FileNotFoundException - if the specified file is not found
throws:
  IllegalArgumentException - if the specified coding does not exist



Scanner
public Scanner(String src)(Code)
Constructs a scanner that uses String as its input.
Parameters:
  src - the string to be scanned



Scanner
public Scanner(InputStream src)(Code)
Constructs a scanner that uses InputStream as its input. The default charset is applied when decoding the input.
Parameters:
  src - the input stream to be scanned



Scanner
public Scanner(InputStream src, String charsetName)(Code)
Constructs a scanner that uses InputStream as its input. The specified charset is applied when decoding the input.
Parameters:
  src - the input stream to be scanned
Parameters:
  charsetName - the encoding type of the input stream
throws:
  IllegalArgumentException - if the specified character set is not found



Scanner
public Scanner(Readable src)(Code)
Constructs a scanner that uses Readable as its input.
Parameters:
  src - the Readable to be scanned



Scanner
public Scanner(ReadableByteChannel src)(Code)
Constructs a scanner that uses ReadableByteChannel as its input. The default charset is applied when decoding the input.
Parameters:
  src - the ReadableByteChannel to be scanned



Scanner
public Scanner(ReadableByteChannel src, String charsetName)(Code)
Constructs a scanner that uses ReadableByteChannel as its input. The specified charset is applied when decoding the input.
Parameters:
  src - the ReadableByteChannel to be scanned
Parameters:
  charsetName - the encoding type of the content in the ReadableByteChannel
throws:
  IllegalArgumentException - if the specified character set is not found




Method Detail
close
public void close()(Code)
Closes the underlying input if the input implements Closeable. If the scanner has been closed, this method will take no effect. The scanning operation after calling this method will throw IllegalStateException



delimiter
public Pattern delimiter()(Code)
Returns the Pattern in use by this scanner. the Pattern presently in use by this scanner



findInLine
public String findInLine(Pattern pattern)(Code)
Tries to find the pattern in input. Delimiters are ignored. If the pattern is found before line terminator, the matched string will be returned, and the scanner will advance to the end of the matched string. Otherwise, null will be returned and the scanner will not advance the input. When waiting for input, the scanner may be blocked. All the input may be cached if no line terminator exists in the buffer.
Parameters:
  pattern - the pattern used to match input the matched string
throws:
  IllegalStateException - if the scanner is closed



findInLine
public String findInLine(String pattern)(Code)
Tries to find the pattern compiled from the specified string. The delimiter will be ignored. It is the same as invoke findInLine(Pattern.compile(pattern))
Parameters:
  pattern - a string used to construct a pattern which in turn used tomatch input the matched string
throws:
  IllegalStateException - if the scanner is closed



findWithinHorizon
public String findWithinHorizon(Pattern pattern, int horizon)(Code)
Tries to find the pattern in input from current position to the specified horizon. Delimiters are ignored. If the pattern is found, the matched string will be returned, and the scanner will advance to the end of the matched string. Otherwise, null will be returned and scanner will not advance the input. When waiting for input, the scanner may be blocked. Scanner will never search exceed horizon code points from current position. The position of horizon does have effects on the result of match. For example, when input is "123", and current position is at zero, findWithinHorizon(Pattern.compile("\\p{Digit}{3}"), 2) will return null. While findWithinHorizon(Pattern.compile("\\p{Digit}{3}"), 3) will return "123". Horizon is treated as a transparent, non-anchoring bound. (refer to Matcher.useTransparentBounds and Matcher.useAnchoringBounds ) Horizon whose value is zero will be ignored and the whole input will be used for search. Under this situation, all the input may be cached. An IllegalArgumentException will be thrown out if horizon is less than zero.
Parameters:
  pattern - the pattern used to scan
Parameters:
  horizon - the search limit the matched string
throws:
  IllegalStateException - if the scanner is closed
throws:
  IllegalArgumentException - if horizon is less than zero



findWithinHorizon
public String findWithinHorizon(String pattern, int horizon)(Code)
Tries to find the pattern in input from current position to the specified horizon. Delimiters are ignored. It is the same as invoke findWithinHorizon(Pattern.compile(pattern)).
Parameters:
  pattern - the pattern used to scan
Parameters:
  horizon - the search limit the matched string
throws:
  IllegalStateException - if the scanner is closed
throws:
  IllegalArgumentException - if horizon is less than zero



hasNext
public boolean hasNext()(Code)
Returns true if this scanner has one or more tokens remaining to parse. Will block if the data is still being read. true if this scanner has one or more tokens remaining
throws:
  IllegalStateException - if the scanner has been closed



hasNext
public boolean hasNext(Pattern pattern)(Code)
Returns true if this scanner has one or more tokens remaining to parse and the next token matches the given pattern. Will block if the data is still being read.
Parameters:
  pattern - the pattern to check for true if this scanner has more tokens and the next token matchesthe pattern
throws:
  IllegalStateException - if the scanner has been closed



hasNext
public boolean hasNext(String pattern)(Code)
Returns true if this scanner has one or more tokens remaining to parse and the next token matches a pattern compiled from the given string. Will block if the data is still being read. Equivalent to hasNext(Pattern.compile(pattern)).
Parameters:
  pattern - the string representation of the pattern to check for true if this scanner has more tokens and the next token matchesthe pattern
throws:
  IllegalStateException - if the scanner has been closed



hasNextBigDecimal
public boolean hasNextBigDecimal()(Code)
Returns true if this scanner's next token can be translated into a valid BigDecimal. true if the next token in this scanner's input can be translatedinto a valid BigDecimal
throws:
  IllegalStateException - if the scanner has been closed



hasNextBigInteger
public boolean hasNextBigInteger()(Code)
Returns true if this scanner's next token can be translated into a valid BigInteger in the default radix. true if the next token in this scanner's input can be translatedinto a valid BigInteger
throws:
  IllegalStateException - if the scanner has been closed



hasNextBigInteger
public boolean hasNextBigInteger(int radix)(Code)
Returns true if this scanner's next token can be translated into a valid BigInteger in the specified radix.
Parameters:
  radix - the radix used to translate the token into a BigInteger true if the next token in this scanner's input can be translatedinto a valid BigInteger
throws:
  IllegalStateException - if the scanner has been closed



hasNextBoolean
public boolean hasNextBoolean()(Code)
Returns true if this scanner's next token can be translated into a valid boolean value. true if the next token in this scanner's input can be translatedinto a valid boolean value
throws:
  IllegalStateException - if the scanner has been closed



hasNextByte
public boolean hasNextByte()(Code)
Returns true if this scanner's next token can be translated into a valid byte value in the default radix. true if the next token in this scanner's input can be translatedinto a valid byte value
throws:
  IllegalStateException - if the scanner has been closed



hasNextByte
public boolean hasNextByte(int radix)(Code)
Returns true if this scanner's next token can be translated into a valid byte value in the specified radix.
Parameters:
  radix - the radix used to translate the token into a byte value true if the next token in this scanner's input can be translatedinto a valid byte value
throws:
  IllegalStateException - if the scanner has been closed



hasNextDouble
public boolean hasNextDouble()(Code)
Returns true if this scanner's next token can be translated into a valid double value. true if the next token in this scanner's input can be translatedinto a valid double value
throws:
  IllegalStateException - if the scanner has been closed



hasNextFloat
public boolean hasNextFloat()(Code)
Returns true if this scanner's next token can be translated into a valid float value. true if the next token in this scanner's input can be translatedinto a valid float value
throws:
  IllegalStateException - if the scanner has been closed



hasNextInt
public boolean hasNextInt()(Code)
Returns true if this scanner's next token can be translated into a valid int value in the default radix. true if the next token in this scanner's input can be translatedinto a valid int value
throws:
  IllegalStateException - if the scanner has been closed



hasNextInt
public boolean hasNextInt(int radix)(Code)
Returns true if this scanner's next token can be translated into a valid int value in the specified radix.
Parameters:
  radix - the radix used to translate the token into an int value true if the next token in this scanner's input can be translatedinto a valid int value
throws:
  IllegalStateException - if the scanner has been closed



hasNextLine
public boolean hasNextLine()(Code)
Returns true if there is another line in the input. Otherwise, returns false. When waiting for input, the scanner may be blocked. true if there is another line in the input. Otherwise, false willbe returned.
throws:
  IllegalStateException - if the scanner is closed



hasNextLong
public boolean hasNextLong()(Code)
Returns true if this scanner's next token can be translated into a valid long value in the default radix. true if the next token in this scanner's input can be translatedinto a valid long value
throws:
  IllegalStateException - if the scanner has been closed



hasNextLong
public boolean hasNextLong(int radix)(Code)
Returns true if this scanner's next token can be translated into a valid long value in the specified radix.
Parameters:
  radix - the radix used to translate the token into a long value true if the next token in this scanner's input can be translatedinto a valid long value
throws:
  IllegalStateException - if the scanner has been closed



hasNextShort
public boolean hasNextShort()(Code)
Returns true if this scanner's next token can be translated into a valid short value in the default radix. true if the next token in this scanner's input can be translatedinto a valid short value
throws:
  IllegalStateException - if the scanner has been closed



hasNextShort
public boolean hasNextShort(int radix)(Code)
Returns true if this scanner's next token can be translated into a valid short value in the specified radix.
Parameters:
  radix - the radix used to translate the token into a short value true if the next token in this scanner's input can be translatedinto a valid short value
throws:
  IllegalStateException - if the scanner has been closed



ioException
public IOException ioException()(Code)
Returns the last IOException thrown when reading the underlying input. If no exception is thrown, return null. the last IOException thrown



locale
public Locale locale()(Code)
Return the locale of this scanner. the locale of this scanner



match
public MatchResult match()(Code)
Returns the match result of this scanner's last match operation.This method throws IllegalStateException if no match operation has been performed, or if the last match was unsuccessful. The various nextXXX methods of Scanner provide a match result if they do not complete with throwing an exception. For example, after an invocation of the nextBoolean() method which returned a boolean value, this method returns a match result for the search of the Boolean regular expression defined above. In the same way,the findInLine(java.lang.String), findWithinHorizon(java.lang.String, int), and skip(java.util.regex.Pattern) methods will provide a match result if they are successful. the match result of the last match operation
throws:
  IllegalStateException - if the match result is not available



next
public String next()(Code)
Returns the next token. The token will be both prefixed and postfixed by the delimiter that is currently being used (or a string that matches the delimiter pattern). Will block if input is being read. the next token
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted



next
public String next(Pattern pattern)(Code)
Returns the next token if it matches the specified pattern. The token will be both prefixed and postfixed by the delimiter that is currently being used (or a string that matches the delimiter pattern). Will block if input is being read.
Parameters:
  pattern - the pattern to check for the next token
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token does not match the pattern given



next
public String next(String pattern)(Code)
Returns the next token if it matches the specified pattern. The token will be both prefixed and postfixed by the delimiter that is currently being used (or a string that matches the delimiter pattern). Will block if input is being read. Equivalent to next(Pattern.compile(pattern)).
Parameters:
  pattern - the string representation of the pattern to check for the next token
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token does not match the pattern given



nextBigDecimal
public BigDecimal nextBigDecimal()(Code)
Returns the next token as a BigDecimal. Will block if input is being read. If the next token can be translated into a BigDecimal the following is done: All locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via Character.digit(charint) , a negative sign (-) is added if the locale specific negative prefix or suffix was present. Finally the resulting String is passed to BigDecimal.BigDecimal(String) }. the next token as a BigDecimal
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a validBigDecimal



nextBigInteger
public BigInteger nextBigInteger()(Code)
Returns the next token as a BigInteger. Will block if input is being read. Equivalent to nextBigInteger(DEFAULT_RADIX) the next token as a BigInteger
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a validBigInteger



nextBigInteger
public BigInteger nextBigInteger(int radix)(Code)
Returns the next token as a BigInteger with the specified radix. Will block if input is being read. If the next token can be translated into a BigInteger the following is done: All locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via Character.digit(charint) , a negative sign (-) is added if the locale specific negative prefix or suffix was present. Finally the resulting String is passed to BigInteger.BigInteger(Stringint) } with the specified radix.
Parameters:
  radix - the radix used to translate the token into a BigInteger the next token as a BigInteger
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a validBigInteger



nextBoolean
public boolean nextBoolean()(Code)
Returns the next token as a boolean. Will block if input is being read. the next token as a boolean
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid booleanvalue



nextByte
public byte nextByte()(Code)
Returns the next token as a byte. Will block if input is being read. Equivalent to nextByte(DEFAULT_RADIX) the next token as a byte
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid bytevalue



nextByte
public byte nextByte(int radix)(Code)
Returns the next token as a byte with the specified radix. Will block if input is being read. If the next token can be translated into a byte the following is done: All locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via Character.digit(charint) , a negative sign (-) is added if the locale specific negative prefix or suffix was present. Finally the resulting String is passed to Byte.parseByte(Stringint) } with the specified radix.
Parameters:
  radix - the radix used to translate the token into byte value the next token as a byte
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid bytevalue



nextDouble
public double nextDouble()(Code)
Returns the next token as a double. Will block if input is being read. If the next token can be translated into a double the following is done: All locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via Character.digit(charint) , a negative sign (-) is added if the locale specific negative prefix or suffix was present. Finally the resulting String is passed to Double.parseDouble(String) }. If the token matches the localized NaN or infinity strings, it is also passed to Double.parseDouble(String) }. the next token as a double
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid doublevalue



nextFloat
public float nextFloat()(Code)
Returns the next token as a float. Will block if input is being read. If the next token can be translated into a float the following is done: All locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via Character.digit(charint) , a negative sign (-) is added if the locale specific negative prefix or suffix was present. Finally the resulting String is passed to Float.parseFloat(String) }.If the token matches the localized NaN or infinity strings, it is also passed to Float.parseFloat(String) }. the next token as a float
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid floatvalue



nextInt
public int nextInt()(Code)
Returns the next token as an int. Will block if input is being read. Equivalent to nextInt(DEFAULT_RADIX). the next token as an int
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid intvalue



nextInt
public int nextInt(int radix)(Code)
Returns the next token as an int with the specified radix. Will block if input is being read. If the next token can be translated into an int the following is done: All locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via Character.digit(charint) , a negative sign (-) is added if the locale specific negative prefix or suffix was present. Finally the resulting String is passed to Integer.parseInt(Stringint) with the specified radix.
Parameters:
  radix - the radix used to translate the token into an int value the next token as an int
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid intvalue



nextLine
public String nextLine()(Code)
Returns the skipped input and advances the scanner to the beginning of the next line. The returned result will exclude any line terminator. When searching, if no line terminator is found, then a large amount of input will be cached. If no line at all can be found, a NoSuchElementException will be thrown out. the skipped line
throws:
  IllegalStateException - if the scanner is closed
throws:
  NoSuchElementException - if no line can be found, e.g. when input is an empty string



nextLong
public long nextLong()(Code)
Returns the next token as a long. Will block if input is being read. Equivalent to nextLong(DEFAULT_RADIX). the next token as a long
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid longvalue



nextLong
public long nextLong(int radix)(Code)
Returns the next token as a long with the specified radix. Will block if input is being read. If the next token can be translated into a long the following is done: All locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via Character.digit(charint) , a negative sign (-) is added if the locale specific negative prefix or suffix was present. Finally the resulting String is passed to Long.parseLong(Stringint) } with the specified radix.
Parameters:
  radix - the radix used to translate the token into a long value the long value scanned from the input
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid longvalue



nextShort
public short nextShort()(Code)
Returns the next token as a short. Will block if input is being read. Equivalent to nextShort(DEFAULT_RADIX). the next token as a short
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid shortvalue



nextShort
public short nextShort(int radix)(Code)
Returns the next token as a short with the specified radix. Will block if input is being read. If the next token can be translated into a short the following is done: All locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via Character.digit(charint) , a negative sign (-) is added if the locale specific negative prefix or suffix was present. Finally the resulting String is passed to Short.parseShort(Stringint) } with the specified radix.
Parameters:
  radix - the radix used to translate the token into short value the short value scanned from the input
throws:
  IllegalStateException - if this scanner has been closed
throws:
  NoSuchElementException - if input has been exhausted
throws:
  InputMismatchException - if the next token can not be translated into a valid shortvalue



radix
public int radix()(Code)
Return the radix of this scanner. the radix of this scanner



remove
public void remove()(Code)
Remove is not a supported operation on Scanner.
throws:
  UnsupportedOperationException - if this method is invoked



skip
public Scanner skip(Pattern pattern)(Code)
Tries to use specified pattern to match input from the current position. The delimiter will be ignored. If matches, the matched input will be skipped. If an anchored match of the specified pattern succeeds, input will also be skipped. Otherwise, a NoSuchElementException will be thrown out. Patterns that can match a lot of input may cause the scanner to read in a large amount of input. Uses a pattern that matches nothing( sc.skip(Pattern.compile("[ \t]*")) ) will suppress NoSuchElementException.
Parameters:
  pattern - used to skip over input the scanner itself
throws:
  IllegalStateException - if the scanner is closed
throws:
  NoSuchElementException - if the specified pattern match fails



skip
public Scanner skip(String pattern)(Code)
Tries to use the specified string to construct a pattern. And then uses the constructed pattern to match input from the current position. The delimiter will be ignored. It is the same as invoke skip(Pattern.compile(pattern))
Parameters:
  pattern - the string used to construct a pattern which in turn used tomatch input the matched input
throws:
  IllegalStateException - if the scanner is closed



toString
public String toString()(Code)
Returns a string. The string is used to represent this scanner. Contained information may be helpful for debugging. The format of the string is unspecified. a string to represent this scanner



useDelimiter
public Scanner useDelimiter(Pattern pattern)(Code)
Set the delimiting pattern of this scanner
Parameters:
  pattern - the delimiting pattern to use this scanner



useDelimiter
public Scanner useDelimiter(String pattern)(Code)
Set the delimiting pattern of this scanner with a pattern compiled from the supplied string value
Parameters:
  pattern - a string from which a Pattern can be compiled this scanner



useLocale
public Scanner useLocale(Locale l)(Code)
Set the locale of this scanner to a specified locale.
Parameters:
  l - the specified locale to use this scanner



useRadix
public Scanner useRadix(int radix)(Code)
Set the radix of this scanner to the specified radix.
Parameters:
  radix - the specified radix to use this scanner



Methods inherited from java.lang.Object
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object object)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final public Class<? extends Object> getClass()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
final public void notify()(Code)(Java Doc)
final public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final public void wait(long millis, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait(long millis) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.