public class BufferedReaderDemo {
   public static void main(String[] args) throws Exception {
      String s ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      StringReader sr = null; 
      BufferedReader br = null;

      try {
         // create and assign a new string reader
         sr = new StringReader(s);
         
         // create  new buffered reader
         br = new BufferedReader(sr);

         // reads and prints BufferedReader
         int value = 0;
         
         while((value = br.read()) != -1) {
         
            // skips a character
            br.skip(1);
            System.out.print((char)value);
         }
         
      } catch (Exception e) {
         // exception occurred.
         e.printStackTrace();
      } finally {
         // releases any system resources associated with the stream
         if(sr!=null)
            sr.close();
         if(br!=null)
            br.close();
      }
   }
}

        

public class BufferedReaderSkip {

	public static void main(String[] args) {
		System.out.print("Enter a sample string: ");
		// declare the BufferedReader Class
		// used the InputStreamReader to read the console input
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		// catch the possible IOException by the read() method
		try {
			// skip 8 characters on the input stream
			reader.skip(8);
			// print what is remaining on the input stream
			System.out.println("Output:"+reader.readLine());

			// close the BufferedReader object
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

        

public class App {
 
    public static void main(String[] args) {
 
        try {
 
            InputStream inputStream = new FileInputStream("C:\\technicalkeeda\\hello.txt");
 
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
 
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
 
            int i;
            while ((i = bufferedReader.read()) != -1) {
 
                char c = (char) i;
                bufferedReader.skip(1);
 
                System.out.print(c + " ");
            }
 
            bufferedReader.close();
            inputStreamReader.close();
            inputStream.close();
 
        } catch (Exception e) {
            e.printStackTrace();
        }
 
    }
}

        

public class Main {
  public static void main(String[] args) throws Exception {

    String s = "from java2s.com";

    // create and assign a new string reader
    StringReader sr = new StringReader(s);

    // create new buffered reader
    BufferedReader br = new BufferedReader(sr);

    // reads and prints BufferedReader
    int value = 0;
    while ((value = br.read()) != -1) {
      // skips a character
      br.skip(1);
      System.out.print((char) value);
    }

  }
}

        

public void givenBufferedReader_whensSkipChars_thenOk() throws IOException {
    StringBuilder result = new StringBuilder();
 
    try (BufferedReader reader = 
           new BufferedReader(new StringReader("1__2__3__4__5"))) {
        int value;
        while ((value = reader.read()) != -1) {
            result.append((char) value);
            reader.skip(2L);
        }
    }
 
    assertEquals("12345", result);
}

        

private boolean loadRequestsFromFile(int numbersToLoad, long startOffset, int firstID) {

    int id = firstID;
    long offset = startOffset < 0 ? 0 : startOffset;

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(mRequestStoreFile), "UTF-8"));
        reader.skip(offset);
        try {
            String line;
            int ind = 0;
            //set offset for first id
            mIDs.put(id, offset);
            while ((line = reader.readLine()) != null && ind++ < numbersToLoad && mURLCache.get(id) == null) {
                if (mIDs.get(id) == null)
                    WebtrekkLogging.log("File is more then existed keys. Error. Key:" + id + " offset:" + offset);
                //put URL and increment id
                mLoaddedIDs.put(id++, line);
                offset += (line.length() + System.getProperty("line.separator").length());
               //set offset of next id if exists
                if (mIDs.get(id) != null && (mLatestSavedURLID >= id || mLatestSavedURLID == -1) )
                    mIDs.put(id, offset);
            }
        } finally {
            reader.close();
        }

    } catch (Exception e) {
        WebtrekkLogging.log("cannot load backup file '" + mRequestStoreFile.getAbsolutePath() + "'", e);
        return false;
    }

    return true;
}

        

private void initConsistentReader() throws IOException {
    consistentReader = new BufferedReader(createReader());
    if (isSkipFirstLine && !this.offsets.isEmpty()) {
        consistentReader.skip(this.offsets.get(0)); //TODO: any other ideas how skip header?
    }
}

        

private TextFileReader(FileSystem fs, Path file, Map<String, Object> conf, TextFileReader.Offset startOffset)
  throws IOException {
  super(fs, file);
  offset = startOffset;
  FSDataInputStream in = fs.open(file);
  String charSet = (conf == null || !conf.containsKey(CHARSET)) ? "UTF-8" : conf.get(CHARSET).toString();
  int buffSz =
    (conf == null || !conf.containsKey(BUFFER_SIZE)) ? DEFAULT_BUFF_SIZE : Integer.parseInt(conf.get(BUFFER_SIZE).toString());
  reader = new BufferedReader(new InputStreamReader(in, charSet), buffSz);
  if (offset.charOffset > 0) {
    reader.skip(offset.charOffset);
  }
}

        

private void tryToDeleteFromFile(final RegionByOffset regionByOffset) throws IOException {
  writeUntilOffsetReached(regionByOffset.getOffset());
  reader.skip(regionByOffset.getLength());
  currentPosition = regionByOffset.getOffsetAfterEnding();
}

        

private void commonInit(Path filePath, Configuration conf) throws IOException {
  readerPosition = start;
  FileSystem fs = filePath.getFileSystem(conf);
  inputReader = new BufferedReader(new InputStreamReader(fs.open(filePath)));
  if (start != 0) {
    // split starts inside the json
    inputReader.skip(start);
    moveToRecordStart();
  }
}        
main