一个字母大小写转换的程序
import java.io.*;
public class Transform 
{    
   public static void main(String []args) throws Exception
   { 
     String str="abcdefg";
     byte buf[]=str.getBytes(str);
     ByteArrayInputStream in =new ByteArrayInputStream(buf);
     ByteArrayOutputStream out=new ByteArrayOutputStream();
         new Transform().TF(in,out);
       byte [] result =  out.toByteArray();
       System.out.println(result);
   }
    public void TF(InputStream in,OutputStream out) 
    {
     int c=0;
     try
     {
    while((c=in.read())!=-1)
    {
       int C=Character.toUpperCase((char)c);
     out.write(C);
    }
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
    
    }  
}
我的jdk是 1.5.0_09  编译通过 但是运行却如下:
Exception in thread "main" java.io.UnsupportedEncodingException: abcdefg
    at sun.io.Converters.getConverterClass(Converters.java:218)
    at sun.io.Converters.newConverter(Converters.java:251)
    at sun.io.CharToByteConverter.getConverter(CharToByteConverter.java:68)
    at java.lang.StringCoding.encode(StringCoding.java:374)
    at java.lang.String.getBytes(String.java:812)
    at Transform.main(Transform.java:7)