📄 configure.java
字号:
import java.io.*;
public class configure
{
private String databaseName="";
private String setupAddress="";
private String runAddress="";
public String setDatabase(String ta,String dn)
{
setupAddress=ta+"\\";
databaseName=dn;
File file=null;
file=new File(setupAddress+"information\\databases.txt");
if(!file.exists())
{
System.out.println("文件不存在");
System.exit(1);
}
else
{
//在数据库资料文档中查找该数据库
FileReader fr=null;
try
{
fr=new FileReader(file);
}
catch(FileNotFoundException e){}
BufferedReader br=new BufferedReader(fr);
int start=0,mid=0;
dealMessage cutingMessage=new dealMessage();
String s="",tempString="";
try
{
while((s=br.readLine())!=null)
{
mid=s.indexOf("|||");
tempString=cutingMessage.cutMessage(s,start,mid);
if(tempString.equals(databaseName))
{ setSSL(s);
return s;
}
}
fr.close();
}
catch(IOException e){}
}
return "No";
}
public void setSQLConn()
{
File file=null;
FileReader fr=null;
BufferedReader br=null;
//读取数据库类型
try
{
file=new File(setupAddress+"information\\databases.txt");
fr=new FileReader(file);
}
catch(FileNotFoundException e){}
int start=0,mid=0;
dealMessage cutingMessage=new dealMessage();
String s="",tempString="",databaseType="";
try
{
br=new BufferedReader(fr);
while((s=br.readLine())!=null)
{
s=s.replace("|||","\t");
mid=s.indexOf("\t");
tempString=cutingMessage.cutMessage(s,start,mid);
if(tempString.equals(databaseName))
{
start=mid;
mid=s.length();
s=cutingMessage.cutMessage(s,start,mid);
start=0;
mid=s.indexOf("\t");
tempString=cutingMessage.cutMessage(s,start,mid);
databaseType=tempString;
break;
}
}
}
catch(IOException e){}
File file2=null;
RandomAccessFile fw=null;
char buffer[]=null;
byte insertStr[]=null;
long l=0;
//把对应数据库类型的连接方式写入sqlOperation.java
try
{
file=new File(setupAddress+"information\\databaseConnection.txt");
fr=new FileReader(file);
br=new BufferedReader(fr);
while((s=br.readLine())!=null)
{
if(s.equals(databaseType))
{
file2=new File(setupAddress+"code\\sqlOperation.java");
fw=new RandomAccessFile(file2,"rw");
l=fw.getFilePointer();
while((s=fw.readLine())!=null)
{
if((s.indexOf("private String databaseName"))!=-1)
{
s="\tprivate String databaseName=\""+databaseName+"\";"+br.readLine();
insertStr=s.getBytes();
fw.seek(l);
fw.write(insertStr);
break;
}
l=fw.getFilePointer();
}
fw.close();
}
else
{
for(int i=0;i<2;i++)
{
br.readLine();
}
}
}
}
catch(Exception e){}
}
public void setJavaTxt(String ra)
{
//输入保存任务管理信息、日志、临时文档等文件的目录地址
//同时,数据库生成的更新信息文档也在此文件夹中
runAddress=ra;
if(runAddress.lastIndexOf("\\")==(runAddress.length()-1))
{
runAddress+="DB synchronism\\";
}
else
{
runAddress+="\\DB synchronism\\";
}
File file=null;
RandomAccessFile fw=null;
byte insertStr[]=null;
long l=0;
String s="",tempString="";
tempString=runAddress.replace("\\","\\\\");
try
{
file=new File(setupAddress+"code\\inputToDB.java");
fw=new RandomAccessFile(file,"rw");
l=fw.getFilePointer();
while((s=fw.readLine())!=null)
{
if((s.indexOf("private static String databaseName"))!=-1)
{
s="\tprivate static String databaseName=\""+databaseName+"\";private static String txtAddress=\""+setupAddress.replace("\\","\\\\")+"\";";
insertStr=s.getBytes();
fw.seek(l);
fw.write(insertStr);
break;
}
l=fw.getFilePointer();
}
fw.close();
}
catch(Exception e){}
try
{
File myDir=new File(runAddress,"DB synchronism");
if(!myDir.exists())
{
if(myDir.mkdir())
{
file=new File(setupAddress+"code\\checkTimeControlThread.java");
fw=new RandomAccessFile(file,"rw");
l=fw.getFilePointer();
while((s=fw.readLine())!=null)
{
if((s.indexOf("private String databaseName"))!=-1)
{
s="\tprivate String databaseName=\""+databaseName+"\";private String txtAddress=\""+tempString+"\";";
insertStr=s.getBytes();
fw.seek(l);
fw.write(insertStr);
break;
}
l=fw.getFilePointer();
}
fw.close();
}
}
}
catch(Exception e){}
try
{
file=new File(setupAddress+"code\\socketReceiver.java");
fw=new RandomAccessFile(file,"rw");
l=fw.getFilePointer();
while((s=fw.readLine())!=null)
{
if((s.indexOf("private static String databaseName"))!=-1)
{
s="\tprivate static String databaseName=\""+databaseName+"\";private static String txtAddress=\""+tempString+"\";";
insertStr=s.getBytes();
fw.seek(l);
fw.write(insertStr);
break;
}
l=fw.getFilePointer();
}
fw.close();
}
catch(Exception e){}
try
{
file=new File(setupAddress+"code\\runFrame.java");
fw=new RandomAccessFile(file,"rw");
l=fw.getFilePointer();
while((s=fw.readLine())!=null)
{
if((s.indexOf("private static String databaseName"))!=-1)
{
s="\tprivate static String databaseName=\""+databaseName+"\";private static String txtAddress=\""+tempString+"\";";
insertStr=s.getBytes();
fw.seek(l);
fw.write(insertStr);
break;
}
l=fw.getFilePointer();
}
fw.close();
}
catch(Exception e){}
try
{
file=new File(setupAddress+"code\\triggerInterface.java");
fw=new RandomAccessFile(file,"rw");
l=fw.getFilePointer();
while((s=fw.readLine())!=null)
{
if((s.indexOf("private static String databaseName"))!=-1)
{
s="\tprivate static String databaseName=\""+databaseName+"\";private static String txtAddress=\""+tempString+"\";";
insertStr=s.getBytes();
fw.seek(l);
fw.write(insertStr);
break;
}
l=fw.getFilePointer();
}
fw.close();
}
catch(Exception e){}
Key k=null;
try
{
k=new Key(runAddress);
k.createKey();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void setSSL(String ss)
{
String sslName="",s="";
int start=0,mid=0;
dealMessage cutingMessage=new dealMessage();
s=ss.replace("|||","\t");
start=s.indexOf("\t");
mid=s.length();
s=cutingMessage.cutMessage(s,start,mid);
start=s.indexOf("\t");
mid=s.length();
s=cutingMessage.cutMessage(s,start,mid);
start=0;
mid=s.indexOf("\t");
sslName=cutingMessage.cutMessage(s,start,mid);
RandomAccessFile fw=null;
BufferedReader br=null;
byte insertStr[]=null;
long l=0;
File file=new File(setupAddress+"code\\"+sslName);
if(file.exists())
{
try
{
file=new File(setupAddress+"code\\runAgent.bat");
fw=new RandomAccessFile(file,"rw");
fw.seek(l);
s="javac runAgent.java\r\nC:\\Borland\\JBuilder2006\\jdk1.5\\bin\\java -Djavax.net.ssl.trustStore="+sslName+" runAgent";
insertStr=s.getBytes();
fw.write(insertStr);
fw.close();
file=new File(setupAddress+"code\\socketReceiver.bat");
fw=new RandomAccessFile(file,"rw");
s="javac runAgent.java\r\nC:\\Borland\\JBuilder2006\\jdk1.5\\bin\\java -Djavax.net.ssl.trustStore="+sslName+" socketReceiver";
insertStr=s.getBytes();
fw.write(insertStr);
fw.close();
}
catch(Exception e){}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -