Java 异常处理
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
public class ExceptionDefaultHandler
{
private final static String _relativeExceptionLogPath = "log";
private final static String _defaultExceptionLogFileName = "exception.log";
// private static boolean hasFile = false;
private static void generateDefaultLogFile()
{
String absoluteFilePath = ProjectConfig.getNFSCAbsolutePath() +
File.separator + _relativeExceptionLogPath + File.separator +
_defaultExceptionLogFileName;
File file = new File(absoluteFilePath);
if(!file.exists())
{
try
{
file.createNewFile();
}
catch(IOException EX)
{
System.out.println(EX.toString());
}
}
}
private static void generateLogFile(String fileName)
{
String absoluteFilePath = ProjectConfig.getNFSCAbsolutePath() +
File.separator + _relativeExceptionLogPath + File.separator + fileName;
File file = new File(absoluteFilePath);
if(!file.exists())
{
try
{
file.createNewFile();
}
catch(IOException ex)
{
System.out.println(ex.toString());
}
}
}
public static void handle(Exception ex, String fileName)
{
generateLogFile(fileName);
String absoluteFilePath = ProjectConfig.getNFSCAbsolutePath() +
File.separator + _relativeExceptionLogPath+ File.separator + fileName;
File file = new File(absoluteFilePath);
if(file.canWrite())
{
boolean appendFlag = true;
if(file.length() > 1000000)
{
appendFlag = false;
}
PrintWriter streamWriter = null;
try
{
streamWriter = new PrintWriter(new FileOutputStream(file, appendFlag));
streamWriter.write("----------------------------------------------------------------");
streamWriter.write(DateTimeUtil.getCurrentDateLocalFormatString());
streamWriter.write("---------------------------------------------------
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
JAVA虚拟机有一个字符串池,对于字符串池的访问可以使用字符串对象的intern()方法,可动态向池中添加对象,它的定义如下:
public native String intern();
这是一个本地方法,在调用这个方法时,JAVA虚拟机首先检查字符串池中是否存在与该字符串对象值相等的对象,如果存在就返回字符串池中的对象的引用,否则就新创建一个 ......
JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法;对于任意一个对象,都能够调用它的任意一个方法;这种动态获取的信息以及动态调用对象的方法的功能称为java语言的反射机制。
Java反射机制主要提供了以下功能: 在运行时判断任意一个对象所属的类;在运行时构造任意一个类的对 ......
安装与设置JDK
Sun JDK的安装基本上有两种方式:
1. 通过Ubuntu提供的包管理工具进行安装
Ubuntu在其包仓库里都包括有JDK的安装,只要sources.list设置正确,通
过apt-get, aptitude, Synaptic Package
Manager等都能安装,而且相关的设置也容易得多;在Ubuntu的新
发布版本里都带了JDK5.0,和JDK6.0的安装支持,而且 ......
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";
......