configure.java
来自「一个日本流行的,功能较全的开源Web办公管理(Groupware)系统。」· Java 代码 · 共 113 行
JAVA
113 行
package jp.co.sjts.gsession.link;
/*
* 儕儞僋偺婎杮僨乕僞 Configure.java
* Copyright (C) 1999-2000 Japan Total System Co,LTD
* Satoru K <koni@sjts.co.jp>
*/
import java.io.IOException;
import java.io.File;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import jp.co.sjts.gsession.tools.*;
public class Configure extends GSTextFile
{
public static final String FILENAME="configure";
public static final String LABEL_DIRMAX="DirMax";
public static final String LABEL_LINKMAX="LinkMax";
private File file=null;
private int maxDirId=0;
private int maxLinkId=0;
// 僐儞僗僩儔僋僞
public Configure()
{
}
public Configure(String dir) throws GSException
{
File directory = new File(dir);
// 僨傿儗僋僩儕偑懚嵼偟側偄応崌偼嶌惉
if(!directory.exists())
directory.mkdirs();
// 僼傽僀儖偑懚嵼偟側偄応崌偼嶌惉
file = new File(directory,FILENAME);
if(!file.exists())
Save();
}
// MaxDirId偺僀儞僋儕儊儞儞僩
synchronized protected int incMaxDirId(){
maxDirId++;
return maxDirId;
}
// MaxDirId偺僀儞僋儕儊儞儞僩
synchronized protected int decMaxDirId(){
maxDirId--;
return maxDirId;
}
// MaxLinkId偺僀儞僋儕儊儞儞僩
synchronized protected int incLinkId(){
maxLinkId++;
return maxLinkId;
}
// MaxLinkId偺僀儞僋儕儊儞儞僩
synchronized protected int decLinkId(){
maxLinkId--;
return maxLinkId;
}
synchronized protected File GetFile()
{
return file;
}
synchronized protected void Read(BufferedReader bf)
throws GSException
{
try {
String buf=bf.readLine();
String label,value;
while(buf!=null){
StringTokenizer st = new StringTokenizer(buf,"=");
label = st.nextToken();
if(st.hasMoreTokens())
value = st.nextToken();
else
value = "";
checkStore(label,value);
buf=bf.readLine();
}
} catch(IOException e) {
throw new GSException("\"Link configure file\"撉崬傒僄儔乕",e);
}
}
synchronized protected void Write(PrintWriter pw)
throws GSException
{
pw.println(LABEL_DIRMAX+"="+Integer.toString(maxDirId));
pw.println(LABEL_LINKMAX+"="+Integer.toString(maxLinkId));
}
synchronized private void checkStore(String label,String value)
{
if(label.equals(LABEL_DIRMAX)){
maxDirId=Integer.parseInt(value);
}else if(label.equals(LABEL_LINKMAX)){
maxLinkId=Integer.parseInt(value);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?