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;
......
// 创建Excel
String destFileName = tableName + ".xls";//文件名
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=".concat(String .valueOf(destFileNa ......
安装与设置JDK
Sun JDK的安装基本上有两种方式:
1. 通过Ubuntu提供的包管理工具进行安装
Ubuntu在其包仓库里都包括有JDK的安装,只要sources.list设置正确,通
过apt-get, aptitude, Synaptic Package
Manager等都能安装,而且相关的设置也容易得多;在Ubuntu的新
发布版本里都带了JDK5.0,和JDK6.0的安装支持,而且 ......
package server;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Recta ......
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;
public class DocumentUtil
{
public static Document loadXMLByAbsolutePath(String absoluteFilePath, String logFileName)
{
SAXReader saxReader = new SAXReader();
Document document = null;
try ......