📄 gsconv.java
字号:
import java.io.IOException;
import java.io.File;
import java.io.OutputStreamWriter;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.util.Properties;
import jp.co.sjts.gsession.tools.archive.GSJar;
import jp.co.sjts.gsession.tools.archive.GSUnJar;
/**
* <p>GSession 偺僐儞僶乕僞乕 GSconv.java
* <p>Copyright (C) 1999-2000 Japan Total System Co,LTD
*
* @author MASAKATU.O <ookubo@sjts.co.jp>
*/
public class GSconv{
private String strDataDir = null; //僨乕僞僨傿儗僋僩儕
private Properties properties=null;
/**
* 嬫愗傝暥帤僠僃僢僋
*
* @param strPath 僠僃僢僋偡傞僷僗暥帤楍
* @param intMod 0:僒乕僶乕 1:僨傿儗僋僩儕
* @return 曄姺屻僷僗暥帤楍
*/
private String checkPath(String strPath,int intMod){
if (intMod == 0){//僒乕僶乕柤
if (strPath.lastIndexOf("/")==strPath.length()-1){//僷僗偺嵟屻偺嬫愗傝暥帤僠僃僢僋
return strPath;
}else{
return strPath + "/";
}
}else{//僨傿儗僋僩儕
if (strPath.lastIndexOf(File.separator)==strPath.length()-1){//僷僗偺嵟屻偺嬫愗傝暥帤僠僃僢僋
return strPath;
}else{
return strPath + File.separator;
}
}
}
/** 僨乕僞僨傿儗僋僩儕柤庢摼 */
private void GetDataDir() throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
boolean blnFlg = false;//弶婜壔
String buf,buf2;
retry:
while(true) {
System.out.println("僨乕僞偺曐懚愭傪巜掕偟偰偔偩偝偄丅僨僼僅儖僩偺応崌偼儕僞乕儞偱恑傫偱偔偩偝偄丅");
System.out.print("["+strDataDir+"]:"); // 僨僼僅儖僩
buf = reader.readLine(); // 僨乕僞撉傒崬傒
if (buf.length() > 0){
File file = new File(buf);
if(!file.isAbsolute()){
System.out.println("愨懳僷僗偱擖椡偟偰偔偩偝偄丅");
continue retry;
}
if(!file.exists()) {
// 僨傿儗僋僩儕偑懚嵼偟側偄
while(true) {
System.out.println("["+buf+"]"+"偑懚嵼偟傑偣傫丅嵞擖椡偟傑偡偐丅[Y/N]:");
buf2 = reader.readLine();//僨乕僞撉傒崬傒
if(buf2.equalsIgnoreCase("Y")) {
continue retry;
} else if(buf2.equalsIgnoreCase("N")) {
System.exit(0);
}else{
continue;
}
}
}else{
strDataDir = buf;
return;
}
} else {
return;
}
}
}
/** 僀儞僗僩乕儖儊僀儞*/
public static void main(String args[])throws IOException {
int intAuto = 0; //帺摦僀儞僗僩乕儖僼儔僌
String strdelfile = "";
File delfile = null ;
GSconv obj = new GSconv();
obj.properties = System.getProperties();
String pathname = null;
// 僨傿儗僋僩儕柤庢摼丒嶌惉
if(obj.strDataDir==null) {
if (File.pathSeparatorChar==':') {
obj.strDataDir = "/var/GSDATA/";
pathname = "/var/";
}
else {
obj.strDataDir = "c:\\GSDATA";
pathname = "c:\\";
}
if(intAuto==0)
obj.GetDataDir();
}
obj.strDataDir = obj.checkPath(obj.strDataDir,1);
File jfile = new File(obj.strDataDir);
String jarname = jfile.getName() + ".jar";
String unjarDir = jfile.getParent() + File.separator;
String unjarname = pathname + jarname;
File chkfile = new File(unjarname);
OutputStreamWriter osw = new OutputStreamWriter( new FileOutputStream("conv.log"),"EUCJIS");
PrintWriter pw = new PrintWriter(osw);
try {
System.out.println("---------------------------------------------");
System.out.println("僶僢僋傾僢僾僼傽僀儖 " + jarname + " 傪嶌惉拞");
GSJar jar = new GSJar(obj.strDataDir,jarname,pathname);
jar.write();
System.out.println(jarname + "傪 " + pathname + " 偵嶌惉偟傑偟偨");
System.out.println("---------------------------------------------");
System.out.println("");
File file = new File(obj.strDataDir);
String [] data = file.list();
for(int i= 0; i<data.length;i++)
{
// if(data[i].equals("LINK")) {
// System.out.println("LINK愝掕偼柍帠廔椆偟傑偟偨");
// }
// if(data[i].equals("MAIN")) {
// System.out.println("MAIN愝掕偼柍帠廔椆偟傑偟偨");
// }
if(data[i].equals("bulletin")) {
GSbulletin gsbull = new GSbulletin(obj.strDataDir,pw);
System.out.println("bulletin愝掕偼柍帠廔椆偟傑偟偨");
}
// if(data[i].equals("card")) {
// System.out.println("card愝掕偼柍帠廔椆偟傑偟偨");
// }
if(data[i].equals("circular")) {
GScircular gscir = new GScircular(obj.strDataDir,pw);
System.out.println("circular愝掕偼柍帠廔椆偟傑偟偨");
}
// if(data[i].equals("reserve")) {
// System.out.println("reserve愝掕偼柍帠廔椆偟傑偟偨");
// }
if(data[i].equals("schedule")) {
GSschedule gssche = new GSschedule(obj.strDataDir,pw);
System.out.println("schedule愝掕偼柍帠廔椆偟傑偟偨");
}
// if(data[i].equals("timecard")) {
// System.out.println("timecard愝掕偼柍帠廔椆偟傑偟偨");
// }
if(data[i].equals("work")) {
GSwork gswork = new GSwork(obj.strDataDir,pw);
System.out.println("work愝掕偼柍帠廔椆偟傑偟偨");
}
}
//廔椆儊僢僙乕僕
pw.flush();
pw.close();
System.out.println("");
System.out.println("愝掕偼柍帠廔椆偟傑偟偨");
}
catch(IOException ie) {
pw.flush();
pw.close();
System.out.println("僐儞僶乕僩幐攕");
if(chkfile.exists()) {
System.out.println("僨乕僞傪暅媽偟偰偄傑偡");
GSUnJar uj = new GSUnJar(unjarname,unjarDir);
uj.write();
System.out.println("暅媽偑廔椆偟傑偟偨");
}
}
catch(Exception e) {
pw.flush();
pw.close();
System.out.println("僐儞僶乕僩幐攕");
if(chkfile.exists()) {
System.out.println("僨乕僞傪暅媽偟偰偄傑偡");
GSUnJar uj = new GSUnJar(unjarname,unjarDir);
uj.write();
System.out.println("暅媽偑廔椆偟傑偟偨");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -