src/share/classes/java/util/Scanner.java

Print this page




 553         if (floatPattern == null) {
 554             buildFloatAndDecimalPattern();
 555         }
 556         return floatPattern;
 557     }
 558     private Pattern decimalPattern() {
 559         if (decimalPattern == null) {
 560             buildFloatAndDecimalPattern();
 561         }
 562         return decimalPattern;
 563     }
 564 
 565     // Constructors
 566 
 567     /**
 568      * Constructs a <code>Scanner</code> that returns values scanned
 569      * from the specified source delimited by the specified pattern.
 570      *
 571      * @param  source A character source implementing the Readable interface
 572      * @param pattern A delimiting pattern
 573      * @return A scanner with the specified source and pattern
 574      */
 575     private Scanner(Readable source, Pattern pattern) {
 576         assert source != null : "source should not be null";
 577         assert pattern != null : "pattern should not be null";
 578         this.source = source;
 579         delimPattern = pattern;
 580         buf = CharBuffer.allocate(BUFFER_SIZE);
 581         buf.limit(0);
 582         matcher = delimPattern.matcher(buf);
 583         matcher.useTransparentBounds(true);
 584         matcher.useAnchoringBounds(false);
 585         useLocale(Locale.getDefault(Locale.Category.FORMAT));
 586     }
 587 
 588     /**
 589      * Constructs a new <code>Scanner</code> that produces values scanned
 590      * from the specified source.
 591      *
 592      * @param  source A character source implementing the {@link Readable}
 593      *         interface




 553         if (floatPattern == null) {
 554             buildFloatAndDecimalPattern();
 555         }
 556         return floatPattern;
 557     }
 558     private Pattern decimalPattern() {
 559         if (decimalPattern == null) {
 560             buildFloatAndDecimalPattern();
 561         }
 562         return decimalPattern;
 563     }
 564 
 565     // Constructors
 566 
 567     /**
 568      * Constructs a <code>Scanner</code> that returns values scanned
 569      * from the specified source delimited by the specified pattern.
 570      *
 571      * @param source A character source implementing the Readable interface
 572      * @param pattern A delimiting pattern

 573      */
 574     private Scanner(Readable source, Pattern pattern) {
 575         assert source != null : "source should not be null";
 576         assert pattern != null : "pattern should not be null";
 577         this.source = source;
 578         delimPattern = pattern;
 579         buf = CharBuffer.allocate(BUFFER_SIZE);
 580         buf.limit(0);
 581         matcher = delimPattern.matcher(buf);
 582         matcher.useTransparentBounds(true);
 583         matcher.useAnchoringBounds(false);
 584         useLocale(Locale.getDefault(Locale.Category.FORMAT));
 585     }
 586 
 587     /**
 588      * Constructs a new <code>Scanner</code> that produces values scanned
 589      * from the specified source.
 590      *
 591      * @param  source A character source implementing the {@link Readable}
 592      *         interface