git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3255 248e525c-4dfb-0310-94bc-949c084e9493
55 lines
1.4 KiB
Plaintext
55 lines
1.4 KiB
Plaintext
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED DirList AS
|
|
import java.io.*;
|
|
import java.sql.*;
|
|
import java.util.Date;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
public class DirList
|
|
{
|
|
public static void getList(String directory)
|
|
throws SQLException
|
|
{
|
|
File path = new File( directory );
|
|
String[] list = path.list();
|
|
String element;
|
|
|
|
for(int i = 0; i < list.length; i++)
|
|
{
|
|
element = list[i];
|
|
|
|
|
|
String fpath=directory+"/"+list[i];
|
|
|
|
File f = new File(fpath);
|
|
|
|
long len;
|
|
Date date;
|
|
|
|
String ftype;
|
|
String sqldate;
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
|
|
|
|
if (f.isFile()) {
|
|
|
|
len = f.length();
|
|
date = new Date(f.lastModified());
|
|
sqldate = df.format(date) ;
|
|
ftype = "F";
|
|
|
|
} else {
|
|
|
|
len = 0;
|
|
sqldate = null;
|
|
ftype = "D";
|
|
}
|
|
|
|
#sql { INSERT INTO GTT_DIR_LIST (FILENAME, filelength, filetype, filemodified)
|
|
VALUES (:element, :len, :ftype, to_date(:sqldate,'YYYY-MM-DD HH24:MI:SS')) };
|
|
}
|
|
}
|
|
|
|
}
|
|
/
|