作者在 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;
}
}
{
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;
}
}