Java 文件 Util
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import com.paic.is.dispatch.TMPEntry;
public class FileUtil
{
public static File getFileByRelativePath(String relativePath)
{
String absoluteFilePath = ProjectConfig.getApplicationRootPath() +
File.separator + relativePath;
return new File(absoluteFilePath);
}
public static String getInjectedFEFileContent(String relativeFilePath, String fileContent)
{
String FEString = readFEFileContent(relativeFilePath);
return fileContent + "\n" + FEString;
}
public static String readFEFileContent(String relativeFilePath)
{
String absoluteFilePath = ProjectConfig.getApplicationRootPath() +
File.separator + relativeFilePath;
File FEFile = new File(absoluteFilePath);
StringBuffer sb = new StringBuffer();
if(FEFile.exists() && FEFile.canRead() && !FEFile.isDirectory())
{
FileReader fr = null;
BufferedReader bReader = null;
try
{
fr = new FileReader(FEFile);
bReader = new BufferedReader(fr);
String line = null;
while((line = bReader.readLine()) != null)
{
sb.append("\n" +line);
}
}
catch(FileNotFoundException ex)
{
ExceptionDefaultHandler.handle(ex,
TMPEntry.getCurrentTMPFileName() + ".log");
}
catch(IOException ex)
{
ExceptionDefaultHandler.handle(ex,
TMPEntry.getCurrentTMPFileName() + ".log");
}
finally
{
try
{
if(null != bReader)
{
bReader.close();
}
if(null != fr)
{
fr.close();
}
}
catch(Exception exception)
{
ExceptionDefaultHandler.handle(exception,
TMPEntry.getCurrentTMPFileName() + ".log");
}
}
}
else
{
ThreadLog.MakeLog("We can not find the file : " +relativeFilePath,
TMPEntry.getCurrent
相关文档:
Java 中给数字左边补0 (1)方法一
import java.text.NumberFormat; public class NumberFormatTest { public static void main(String[] args) {
//待测试数据
int i = 1;
......
@echo off cls REM --- BEG MACHINE-DEPENDENT ---- set HOME_J2RE=C:\Program Files\Java\jdk1.5.0_17 REM --- END MACHINE-DEPENDENT ---- set HOME_JAVA=%HOME_J2RE%\bin\java set HOME_JAVA="%HOME_JAVA%" set ARG_MEMORY=-Xms128m -Xmx196m set PROP_POLICY=-Dorg.ragingcat.kst.uikeytool.policy.extende ......
Java 开发为什么需要 UML
知道 UML 造成了怎样的局面大混乱吗?知道什么样的功能是 UML 拥有但 JAVA 不具备的吗?知道我们为什么需要除 JAVA 外的另一种电脑语言吗?UML 并不仅仅只是 JAVA 或者其它什么语言的替代品。UML 是面向对象的分析及设计的注释。UML 是独立于那些传统设计语言之外的一种语言。因为 UML ......
安装与设置JDK
Sun JDK的安装基本上有两种方式:
1. 通过Ubuntu提供的包管理工具进行安装
Ubuntu在其包仓库里都包括有JDK的安装,只要sources.list设置正确,通
过apt-get, aptitude, Synaptic Package
Manager等都能安装,而且相关的设置也容易得多;在Ubuntu的新
发布版本里都带了JDK5.0,和JDK6.0的安装支持,而且 ......
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import com.paic.is.dispatch.TMPEntry;
import javapassword ......