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
相关文档:
// 创建Excel
String destFileName = tableName + ".xls";//文件名
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=".concat(String .valueOf(destFileNa ......
CoreJava多线程
线程的概念:
线程指进程中的一个执行流程,一个进程可以包含多个线程。
每一个进程都独享一块内存空间。每个进程都需要操作系统为其分配独立的内存地址,而同一进程中的多个线程在同一块地址空间工作,他们共享一块内存和资源。
java中有两中方法创建一个多线程类:
1、继承java.lang.Thread类,覆盖T ......
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
public class ThreadLog
{
private final static String _detailLogFile = "log"+File.separator+"detail";
private static boolean _logFlag = true;
priv ......
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import com.paic.is.dispatch.TMPEntry;
public class DateTimeUtil
{
public final static String LOCAL_SHORT_DATE_FORMAT = "yyyy-MM-dd";
public final static String LOCAL_LONG_DATE_FORMAT = "yyyy-MM-dd H ......
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 ......