形如这样的代码Java代码 /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.relyang.util;
import javax.swing.JOptionPane;
/**
*
* @author Rel
*/
public class MyTest {
public static void main(String[] args) throws Exception {
GB2Big5 pTmp = GB2Big5.getInstance();
boolean bIsGB = true;
String flag = JOptionPane.showInputDialog("请输入要转换的格式:gb2b或者b2gb");
if (flag.equals("gb2b")) {
bIsGB = false;
} else if (flag.equals("b2gb")) {
bIsGB = true;
}
// String inStr =JOptionPane.showInputDialog("请输入要转换的字符:");
//读取文本文件
String file = GetText.read("e:\\a.txt");
String inStr = file;
String outStr = "";
if (bIsGB) {
outStr = pTmp.big52gb(inStr);
} else {
outStr = new String(pTmp.gb2big5(inStr), "BIG5");
}
byte[] bytesUTF8 = outStr.getBytes("UTF-8");
byte[] bytesUTF16 = outStr.getBytes("UTF-16");
byte[] bytesUTF32 = outStr.getBytes("UTF-32");
String strutf8 = new String(bytesUTF8, "UTF-8");
String strutf16 = new String(bytesUTF16,"UTF-16");
String strutf32 = new String(bytesUTF32,"UTF-32");
GetText.write("d:\\strutf8.txt", strutf8.toString());
GetText.write("d:\\strutf16.txt", strutf16.toString());
GetText.write("d:\\strutf32.txt", strutf32.toString());
System.out.println("String [" + inStr + "] converted into:\n[" + strutf8 + "]");
System.out.println("String [" + inStr + "] converted into:\n[" + strutf16 + "]");
System.out.println("String [" + inStr + "] converted into:\n[" + strutf32 + "]");
}
}
希望在命令行运行的时候输入参数:java MyTest args1,args2,args3。或者打包成Jar文件: java -jar AAA.jar args1,args2,args3,...形如这样的程序,怎么在main方法里面写啊??那位能帮忙看看,给个demo参考也行,谢谢
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.relyang.util;
import javax.swing.JOptionPane;
/**
*
* @author Rel
*/
public class MyTest {
public static void main(String[] args) throws Exception {
GB2Big5 pTmp = GB2Big5.getInstance();
boolean bIsGB = true;
String flag = JOptionPane.showInputDialog("请输入要转换的格式:gb2b或者b2gb");
if (flag.equals("gb2b")) {
bIsGB = false;
} else if (flag.equals("b2gb")) {
bIsGB = true;
}
// String inStr =JOptionPane.showInputDialog("请输入要转换的字符:");
//读取文本文件
String file = GetText.read("e:\\a.txt");
String inStr = file;
String outStr = "";
if (bIsGB) {
outStr = pTmp.big52gb(inStr);
} else {
outStr = new String(pTmp.gb2big5(inStr), "BIG5");
}
byte[] bytesUTF8 = outStr.getBytes("UTF-8");
byte[] bytesUTF16 = outStr.getBytes("UTF-16");
byte[] bytesUTF32 = outStr.getBytes("UTF-32");
String strutf8 = new String(bytesUTF8, "UTF-8");
String strutf16 = new String(bytesUTF16,"UTF-16");
String strutf32 = new String(bytesUTF32,"UTF-32");
GetText.write("d:\\strutf8.txt", strutf8.toString());
GetText.write("d:\\strutf16.txt", strutf16.toString());
GetText.write("d:\\strutf32.txt", strutf32.toString());
System.out.println("String [" + inStr + "] converted into:\n[" + strutf8 + "]");
System.out.println("String [" + inStr + "] converted into:\n[" + strutf16 + "]");
System.out.println("String [" + inStr + "] converted into:\n[" + strutf32 + "]");
}
}
希望在命令行运行的时候输入参数:java MyTest args1,args2,args3。或者打包成Jar文件: java -jar AAA.jar args1,args2,args3,...形如这样的程序,怎么在main方法里面写啊??那位能帮忙看看,给个demo参考也行,谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货