java如何转码

作者在 2006-12-10 03:19:00 发布以下内容
public class FormatString
{
 private static String format(String str)
   {
       try
       {
           byte[] bytes=str.getBytes("ISO8859_1");
           return new String(bytes);
       }
       catch(Exception e)
       {
           return "";
       }
   }
   public static void main(String args[])
   {
     System.out.println("格式化后的字符串是:"+format("511KB 软件语言:简体中文 软件类别:国外软件/免费版/"));
     System.out.println("格式化后的字符串是:"+format("511KB ????:???? ????:????/???/"));
     System.err.println(finallyDemo());
   }
   public static int finallyDemo()
   {
      try
      {
       System.err.println("try块执行");
       return 1;
      }
     
     catch (Exception e)
       {
           System.err.println(e.getMessage());
       }
       finally
       {
          System.err.println("finally块执行");
       }
       return 2;
   }
}
默认分类 | 阅读 7195 次
文章评论,共0条
游客请输入验证码
文章分类
最新评论