Java byte streams and character streams conversion

Description

Java byte streams and character streams conversion

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);




    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 .ja  v a2s .c o m
    }
    reader.close();
  }
}
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  a2s.c  o  m
    }
    reader.close();
  }
}



PreviousNext

Related