Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.*;
- import java.util.NoSuchElementException;
- public class MyScanner {
- private BufferedReader reader;
- public MyScanner( InputStream in ){
- reader = new BufferedReader( new InputStreamReader( in ) );
- }
- private String curString;
- private String getCurString() throws IOException {
- return reader.readLine();
- }
- private boolean isNotDoubleCheck = true;
- public boolean hasNextLine() throws IOException {
- if( isNotDoubleCheck ){
- curString = getCurString();
- }
- isNotDoubleCheck = false;
- return !curString.isEmpty();
- }
- public String nextLine() throws IOException {
- if( hasNextLine() ){
- isNotDoubleCheck = true;
- return curString;
- }
- else{
- isNotDoubleCheck = true;
- throw new NoSuchElementException( "Next line not found" );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment