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

📄 gstextfile2.java

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


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.io.IOException;

/**
 * <p>嫟捠僥僉僗僩僼傽僀儖梡婎杮僋儔僗2  GSTextFile2.java
 * <p>Copyright (C) 1999-2000 Japan Total System Co,LTD
 *
 * @author   Satoru K   &lt;koni@sjts.co.jp&gt;
 */
abstract public class GSTextFile2
{
	protected static void Lock(String filepath) throws GSException
	{
		File file = new File(filepath+".lock");

		while(file.exists()){
			try	{
				Thread.sleep(100);
			}catch(InterruptedException e){
			}
		}

		file.mkdir();
	}

	protected static void Unlock(String filepath) throws GSException
	{
		File file = new File(filepath+".lock");

		file.delete();
	}

	public static BufferedReader OpenLoad(String filepath) throws GSException
	{
		File file = new File(filepath);
		return OpenLoad(file);
	}

	public static BufferedReader OpenLoad(File file,String enc) throws GSException
	{
		try {
			InputStreamReader isr = new InputStreamReader(new FileInputStream(file),enc);
			return new BufferedReader(isr);
		} catch(FileNotFoundException e) {
			throw new GSException("僼傽僀儖僆乕僾儞偵幐攕(僼傽僀儖偑尒偮偐傝傑偣傫)",e);
		} catch(SecurityException e) {
			throw new GSException("僼傽僀儖僆乕僾儞偵幐攕(尃尷偑偁傝傑偣傫)",e);
		} catch(IOException e) {
			throw new GSException("僼傽僀儖僆乕僾儞偵幐攕",e);
		}
	}

	public static BufferedReader OpenLoad(File file) throws GSException
	{
		return OpenLoad(file,"EUCJIS");
	}

	public static PrintWriter OpenSave(String filepath) throws GSException
	{
		File file = new File(filepath);
		return OpenSave(file);
	}

	public static PrintWriter OpenSave(File file,String enc) throws GSException
	{
		try {
			OutputStreamWriter osw =  new OutputStreamWriter( new FileOutputStream(file),enc);
			return new PrintWriter(osw);
		} catch(FileNotFoundException e) {
			throw new GSException("僼傽僀儖僆乕僾儞偵幐攕(僼傽僀儖偑尒偮偐傝傑偣傫)",e);
		} catch(SecurityException e) {
			throw new GSException("僼傽僀儖僆乕僾儞偵幐攕(尃尷偑偁傝傑偣傫)",e);
		} catch(UnsupportedEncodingException e) {
			throw new GSException("僼傽僀儖僆乕僾儞偵幐攕(僄儞僐乕僪偑僒億乕僩偝傟偰偄側偄)",e);
		} catch(IOException e) {
			throw new GSException("僼傽僀儖僆乕僾儞偵幐攕",e);
		}
	}

	public static PrintWriter OpenSave(File file) throws GSException
	{
		return OpenSave(file,"EUCJIS");
	}

}

⌨️ 快捷键说明

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