Java BufferedReader create from InputStream using "US-ASCII" encoding

Description

Java BufferedReader create from InputStream using "US-ASCII" encoding

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

public class Main {
  public static void main(String[] args) throws Exception {
    InputStream is = new FileInputStream("Main.java");
    Reader r = new InputStreamReader(is,"US-ASCII");




    BufferedReader reader = new BufferedReader(r);
    StringBuilder sb = new StringBuilder();
    String lines = reader.readLine();
    while (lines != null) {
      sb.append(lines.toUpperCase() + "\n");
      lines = reader.readLine();//  www.j a v  a2  s.co  m
    }
    reader.close();
  }
}



PreviousNext

Related