//**************************************************************
//下面的方法是完成文件后缀名的判断,返回的是后缀名首字母的大写形式
public static String getFileType(String fileName)
{
String fileType=null;
if(fileName.endsWith(.txt)) fileType="T";
if(fileName.endsWith(.html))fileType="H";
return fileType;
}
//上面的方法可以返回指定路径下面文件类型值
//下面的方法是获得当前的系统时间
public static String getCurrentTime()
{
String currentDate=null;
//获得日历接口
java.util.Calender d=new java.util.Calender.getInstance();
//定制显示格式
java.text.SimpleDateFormat f=new java.text.SimpleDateFormat("yyMMddhhmmss");
currentDate=f.format(c.getTime());
return currentTime;
}
//下面的方法完成编码的定制
public static String getId(String fileName)
{
String currentTime=getCurrentTime();
String fileType=getFileType(fileName);
return currentTime+"_"+fileType;
}
//上面完成了数据库中某一字段的递增ID的自定义工作,用的时候只需要在相应的方法中调用getId(fileName)方法就可以了。。。。
//下面的方法是完成文件后缀名的判断,返回的是后缀名首字母的大写形式
public static String getFileType(String fileName)
{
String fileType=null;
if(fileName.endsWith(.txt)) fileType="T";
if(fileName.endsWith(.html))fileType="H";
return fileType;
}
//上面的方法可以返回指定路径下面文件类型值
//下面的方法是获得当前的系统时间
public static String getCurrentTime()
{
String currentDate=null;
//获得日历接口
java.util.Calender d=new java.util.Calender.getInstance();
//定制显示格式
java.text.SimpleDateFormat f=new java.text.SimpleDateFormat("yyMMddhhmmss");
currentDate=f.format(c.getTime());
return currentTime;
}
//下面的方法完成编码的定制
public static String getId(String fileName)
{
String currentTime=getCurrentTime();
String fileType=getFileType(fileName);
return currentTime+"_"+fileType;
}
//上面完成了数据库中某一字段的递增ID的自定义工作,用的时候只需要在相应的方法中调用getId(fileName)方法就可以了。。。。