Java 线程中记录日志
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;
private static HashMap<String, String> _threadDetailFile = new HashMap<String, String>();
private static int _fileIndex = 1;
private static void generateLogFile(String fileName)
{
String absoluteFilePath = ProjectConfig.getNFSCAbsolutePath() +
File.separator + "log" + File.separator +fileName;
_threadDetailFile.put(String.valueOf(Thread.currentThread().getId()) + "_" + fileName,
absoluteFilePath);
File file = new File(absoluteFilePath);
//create a new file
if(!file.exists())
{
try
{
file.createNewFile();
}
catch(IOException ex)
{
ExceptionDefaultHandler.handle(ex, "threadlog.log");
}
}
}
private static void generateLogFile()
{
String fileName = _detailLogFile +
DateTimeUtil.getCurrentDateFormatString("yyyyMMddHHmmss") +"_"+
String.valueOf(_fileIndex++)+ ".log";
String absoluteFilePath = ProjectConfig.getNFSCAbsolutePath() +
File.separator + fileName;
_threadDetailFile.put(String.valueOf(Thread.currentThread().getId()), absoluteFilePath);
File file = new File(absoluteFilePath);
//if the file exist, we have to remove it.
if(file.exists())
{
try
{
file.delete();
}
catch(SecurityException ex)
{
ExceptionDefaultHandler.handle(ex, "threadlog.log");
}
}
//create a new file
try
{
file.createNewFile();
}
catch(IOException ex)
{
ExceptionDefaultHandler.handle(ex, "threadlog.log");
}
}
private static boolean hasThreadLogFile()
{
return _threadDetailFile.containsKey(String.valueOf(Thread.currentThread().getId()));
}
private static boolean hasThreadLogFi
相关文档:
package cn.ctgu.edu.ac;
import java.sql.*;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String url="jdbc:sqlserver://localhost:1433;Database=网上书店管理系统;integr ......
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
一.点击图书,展示该书的详细信息
点击图书→books页面→通过url重写displayBook.jsp?isbn=该书编号 →传入displayBooks页面→
<c:set var="isbn" value="${param.isbn}"></c:set>
<c:forEach var="currentBook" items="${sessionScope.bookTitles}">
<c:if test="${ ......
Java 开发为什么需要 UML
知道 UML 造成了怎样的局面大混乱吗?知道什么样的功能是 UML 拥有但 JAVA 不具备的吗?知道我们为什么需要除 JAVA 外的另一种电脑语言吗?UML 并不仅仅只是 JAVA 或者其它什么语言的替代品。UML 是面向对象的分析及设计的注释。UML 是独立于那些传统设计语言之外的一种语言。因为 UML ......
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties;
public class SystemProperties
{
public static String LINE_SEPARATOR = "line.separator";
public static String FILE_SEPARATOR = "file.separator";
public static String USER_LANGUAGE = "user.language";
......