📄 dispatcherdb.java
字号:
package cn.edu.hust.cgcl.biogrid.dispatcher;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class DispatcherDB
{
protected final static String DEF_NAME = "/dispatcherDB.txt";
protected String fileName;
public DispatcherDB()
throws IOException
{
this(DEF_NAME);
}
public DispatcherDB(String fn)
throws IOException
{
fileName = fn;
}
public DispatcherInfo rebuild()
throws IOException
{
File f = new File(fileName);
if (!f.exists())
{
return null;
}
BufferedReader is = new BufferedReader(new FileReader(fileName));
String line;
if ( (line = is.readLine()) != null)
{
String[] result = line.split(":");
DispatcherInfo d=new DispatcherInfo(result[0],
result[1], result[2]);
return d;
}
return null;
}
protected PrintWriter pw;
public synchronized void createDB(DispatcherInfo di)
throws IOException
{
File f = new File(fileName);
if (!f.exists())
{
f.createNewFile();
}
else
{
f.delete();
f.createNewFile();
}
if (pw == null)
{
pw = new PrintWriter(new FileWriter(fileName, true));
}
pw.println(toDB(di));
pw.flush();
}
protected String toDB(DispatcherInfo di)
{
return new StringBuffer().append(di.getDispatcherId()).append(':').
append(di.getFirstMonitorId()).append(':').append(di.getSecondMonitorId()).
append(':').
toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -