⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bldatafile.java

📁 一个日本流行的,功能较全的开源Web办公管理(Groupware)系统。
💻 JAVA
字号:
package jp.co.sjts.gsession.bulletin;

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;
import jp.co.sjts.gsession.tools.*;

/**
 * <p>宖帵斅僨乕僞娗棟梡
 *
 * @author Masakatu O   &lt;ookubo@sjts.co.jp&gt;
 * @author Satoru K   &lt;koni@sjts.co.jp&gt;
 * @author Hideyuki KITADE &lt;aki@sjts.co.jp&gt;
 */
public class BLDataFile extends GSTextFile{

	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.tmptype = tmptype; }

	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() throws GSException{
	}

	/**
	 *
	 *
	 */
	public BLDataFile(String BulletinDir,String GrpId,String BullId) throws GSException{
		properties = System.getProperties();
		String GrpDir = BulletinDir + DIR + GrpId ;
		GrpDir = GrpDir.replace('/',this.properties.getProperty("file.separator").charAt(0));

		File file1 = new File(GrpDir);
		if(!file1.exists())		// 僼傽僀儖偑懚嵼偡傞偐
			file1.mkdirs();		// 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞

		filePath = GrpDir + SPATH + BullId;
		this.file = new File(filePath);
	}

	/**
	 *
	 *
	 */
	public synchronized void Get(String BulletinDir,String GrpId,String BullId) throws GSException{

		properties = System.getProperties();
		String GrpDir = BulletinDir + DIR + GrpId + SPATH + BullId;
		filePath = GrpDir.replace('/',this.properties.getProperty("file.separator").charAt(0));
		this.file = new File(filePath);
		if(file.exists()) {
			Load();
		}
	}

	/**
	 *
	 *
	 */
	public synchronized boolean Getb(String BulletinDir,String GrpId,String BullId) throws GSException{

		filePath = BulletinDir + DIR + GrpId + SPATH + BullId;
		this.file = new File(filePath);
		if(file.exists()) {
			Load();
                        return  true;
                }else{
                        return  false;
		}
	}


	/**
	 * <p>
	 *
	 * @param entuserid
	 * @param name
	 * @param taitol
	 * @param messege
	 * @param limit
	 * @param timestamp
	 * @param tmpfile
	 * @param tmptype
	 */
	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;
	}

	/**
	 * <p>僼傽僀儖僆僽僕僃僋僩偺庢摼
	 *
	 * @return 庢摼偟偨僼傽僀儖
	 */
	synchronized protected File GetFile(){
		return file;
	}

	/**
	 * <p>僨乕僞撉傒崬傒
	 *
	 * @param bf BufferedReader
	 */
	synchronized protected void Read(BufferedReader bf) throws GSException{
		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.delimitDecorde("=",value);
				else if(label.equals(V4))
					messege = GSTool.delimitDecorde("=",value);
				else if(label.equals(V5))
					limit = value;
				else if(label.equals(V6))
					timestamp = value;
				else if(label.equals(V7))
					tmpfile = GSTool.delimitDecorde("=",value);
				else if(label.equals(V8))
					tmptype = GSTool.delimitDecorde("=",value);
			}
		} catch(IOException e) {
			throw new GSException("\"Data file\"撉崬傒僄儔乕");
		}
	}

	/**
	 * <p>僨乕僞傪儔僀僩偟傑偡丅
	 *
	 * @param pw PrintWriter
	 */
	synchronized protected void Write(PrintWriter pw) throws GSException{
		pw.println(V1 + "=" + entuserid);
		pw.println(V2 + "=" + name);
		pw.println(V3 + "=" + GSTool.delimitEncorde("=",taitol));
		pw.println(V4 + "=" + GSTool.delimitEncorde("=",messege));
		pw.println(V5 + "=" + limit);
		pw.println(V6 + "=" + timestamp);
		pw.println(V7 + "=" + GSTool.delimitEncorde("=",tmpfile));
		pw.println(V8 + "=" + GSTool.delimitEncorde("=",tmptype));
	}


	/**
	 * <p>
	 *
	 * @param content
	 */
	public void setContent(byte[] content) throws GSException{
		try{
			FileOutputStream fos = new FileOutputStream(filePath+"b");
			BufferedOutputStream bos = new BufferedOutputStream(fos,content.length+1);
			bos.write(content,0,content.length);
			bos.flush();
			bos.close();
		}catch(FileNotFoundException e){
			throw new GSException("僼傽僀儖偑尒偮偐傝傑偣傫丅",e);
		}catch(IOException e){
			throw new GSException("IO僄儔乕偱偡丅",e);
		}
	}

}

⌨️ 快捷键说明

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