bldatafile_convert.java

来自「一个日本流行的,功能较全的开源Web办公管理(Groupware)系统。」· Java 代码 · 共 162 行

JAVA
162
字号
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.util.Properties;
import java.util.StringTokenizer;

/**
 * <p>宖帵斅僨乕僞僐儞僶乕僞
 * <p>Copyright (C) 1999-2000 Japan Total System Co,LTD
 *
 * @author   Masakatu O   &lt;ookubo@sjts.co.jp&gt;
 * @author   Satoru K   &lt;koni@sjts.co.jp&gt;
 */

public class BLDataFile_convert extends GSTextFile_convert
{
	private String  entuserid="";	// 儐乕僓ID
	private String  name="";		// 儐乕僓柤
	private String  taitol="";		// 僞僀僩儖
	private String  messege="";		// 杮暥
	private String  limit="";		// 桳岠婜尷
	private String  timestamp="";	// 僞僀儉僗僞儞僾
	private String  tmpfile="";		// 揧晅僼傽僀儖
	private String  tmptype="";     // 揧晅僼傽僀儖僞僀僾

	public static final String V1 = "entuserid";	//儐乕僓ID
	public static final String V2 = "name";			//儐乕僓ID
	public static final String V3 = "taitol";		//僞僀僩儖
	public static final String V4 = "messege";		//杮暥
	public static final String V5 = "limit";		//桳岠婜尷
	public static final String V6 = "timestamp";	//僞僀儉僗僞儞僾
	public static final String V7 = "tmpfile";		//揧晅僼傽僀儖
	public static final String V8 = "tmptype";      //揧晅僼傽僀儖僞僀僾

	public final static String SPATH = File.separator ;
	public final static String DIR = "group" + File.separator ;
	private Properties properties=null;
	private File file;
	private String filePath =  null;

	public void setEntuserid(String entuserid) { this.entuserid = entuserid; }
	public void setName(String name) { this.name = name; }
	public void setTaitol(String taitol) { this.taitol = taitol; }
	public void setMessege(String messege) { this.messege = messege; }
	public void setLimit(String limit) { this.limit = limit; }
	public void setTimestamp(String timestamp) { this.timestamp = timestamp; }
	public void setTmpfile(String tmpfile) { this.tmpfile = tmpfile; }
	public void setTmptype(String tmptype) { this.tmpfile = tmpfile; }

	public String getEntuserid() { return entuserid; }
	public String getName() { return name; }
	public String getTaitol() { return taitol; }
	public String getMessege() { return messege; }
	public String getLimit() { return limit; }
	public String getTimestamp() { return timestamp; }
	public String getTmpfile() { return tmpfile; }
	public String getTmptype() { return tmptype; }


	public BLDataFile_convert(String BulletinDir,String GrpId,String BullId,PrintWriter bf) throws Exception
	{
		properties = System.getProperties();
		String GrpDir = BulletinDir + GrpId;
		GrpDir = GrpDir.replace('/',this.properties.getProperty("file.separator").charAt(0));

		File file1 = new File(GrpDir);
		if(file1.exists()) {		// 僼傽僀儖偑懚嵼偡傞偐

			filePath = GrpDir + SPATH + BullId;
			this.file = new File(filePath);
			if(file.exists()){
				bf.println(file.getParent() + File.separator + file.getName());				
				Load();
				Save();
			}
		}
	}

	public BLDataFile_convert() throws Exception
	{
	}

	public void BLData(String entuserid,String name,String taitol,String messege,String limit,String timestamp, String tmpfile, String tmptype)
	{
		this.entuserid = entuserid;
		this.name = name;
		this.taitol = taitol;
		this.messege = messege;
		this.limit = limit;
		this.timestamp = timestamp;
		this.tmpfile = tmpfile;
		this.tmptype = tmptype;
	}


//昁偢偄傞
	synchronized protected File GetFile()
	{
		return file;
	}


	synchronized protected void Read(BufferedReader bf) throws Exception
	{
		try {
			String buf = null;

			tmptype = "application/octet-stream";
			for(buf=bf.readLine();buf!=null;buf=bf.readLine()) {
				StringTokenizer st = new StringTokenizer(buf,"=");
				String label = st.nextToken();
				String value = st.nextToken();
				if(label.equals(V1))
					entuserid = value;
				else if(label.equals(V2))
					name = value;
				else if(label.equals(V3))
					taitol = GSTool_convert.delimitDecorde("=",value);
				else if(label.equals(V4))
					messege = GSTool_convert.delimitDecorde("=",value);
				else if(label.equals(V5)) {
					limit = value;
					if(limit.length() == 8)
						limit = limit + "000000";
				}
				else if(label.equals(V6)) {
					timestamp = value;
					if(timestamp.length() == 12)
						timestamp = timestamp + "00";
				}
				else if(label.equals(V7))
					tmpfile = GSTool_convert.delimitDecorde("=",value);
				else if(label.equals(V8))
					tmptype = GSTool_convert.delimitDecorde("=",value);

			}
		} catch(IOException e) {
			throw new Exception("\"Data file\"撉崬傒僄儔乕");
		}
	}

	synchronized protected void Write(PrintWriter pw) throws Exception
	{
		pw.println(V1 + "=" + entuserid);
		pw.println(V2 + "=" + name);
		pw.println(V3 + "=" + GSTool_convert.delimitEncorde("=",taitol));
		pw.println(V4 + "=" + GSTool_convert.delimitEncorde("=",messege));
		pw.println(V5 + "=" + limit);
		pw.println(V6 + "=" + timestamp);
		pw.println(V7 + "=" + GSTool_convert.delimitEncorde("=",tmpfile));
		pw.println(V8 + "=" + GSTool_convert.delimitEncorde("=",tmptype));
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?