import java.io.*; public class TestTransForm1 { public static void main(String[] args) { try { OutputStreamWriter osw = new OutputStreamWriter( new FileOutputStream("d:\bak\char.txt")); osw.write("mircosoftibmsunapplehp"); System.out.println(osw.getEncoding()); osw.close(); osw = new OutputStreamWriter( new FileOutputStream("d:\bak\char.txt", true), "ISO8859_1"); // latin-1 osw.write("mircosoftibmsunapplehp"); System.out.println(osw.getEncoding()); osw.close(); } catch (IOException e) { e.printStackTrace(); } } }
import java.io.*; public class TestTransForm2 { public static void main(String args[]) { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String s = null; try { s = br.readLine(); while(s!=null){ if(s.equalsIgnoreCase("exit")) break; System.out.println(s.toUpperCase()); s = br.readLine(); } br.close(); } catch (IOException e) { e.printStackTrace(); } } }