Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Getting Directory File list on Unix Box

Thread Tools

Getting Directory File list on Unix Box

Posts: n/a
Again a newbie to JSP.

Here is my dilema:
I have a jsp page that when it loads I need it to read the names of
the files located in a directory on the UNIX web server that hosts the
page. The directory is /u004/qms/ext_tables. Once it knows the names
of the files I need to pass the names of those files to a Oracle
Stored Procedure.

I got the following code to work; however, it was on a Windows box
with a mapped drive to the folder containing the file names I needed
(o:\) When moved off the test box (WINNT) to the production box
(UNIX), the code crashed. I need to modify the following to work with
UNIX. CAN someone plesae help!!!

String sSPName = "ImportNOCCData";
class TxtDocFilter implements FileFilter {
public boolean accept(File f) {
String name = f.getName().toLowerCase();
return name.endsWith(".txt");
File f = new File("o:/");
File[] files = f.listFiles(new TxtDocFilter());
int counter;
for (counter=0; counter<files.length; counter++)
String s = ""+ files[counter] +"";
String CleanPath = s.replaceAll("o:\\\\","");
int iUserID = ((Integer)session.getAttribute("userid")).intValue ();;
// call the SP
CallableStatement oCs = oCn.prepareCall("{CALL " + sSPName + "(?, ?,
?, ?)}");
oCs.setString(1, CleanPath);
oCs.setString(2, "07/20/2004");
oCs.setInt(3, iUserID);
oCs.registerOutParameter(4, java.sql.Types.INTEGER);
oCs.setInt(4, 0);
int iRetVal=oCs.getInt(4);
if (iRetVal>0)
out.print("Import failed. Please contact System Administrator with
a system code of ");
Reply With Quote
Phillip Mills
Posts: n/a
In article <(E-Mail Removed) >, Removed) (TManners) wrote:

> When moved off the test box (WINNT) to the production box
> (UNIX), the code crashed. I need to modify the following to work with

What code did you change for UNIX? (File("o:/") at least, I assume?)

Where did it crash?

What message did you get from the crash?

Phillip Mills
Multi-platform software development
(416) 224-0714
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
div box questions; float text around a box, fit box to image size Gnarlodious HTML 4 05-05-2010 11:30 AM
Re: Getting the list of mount points on a unix like system Roedy Green Java 1 10-30-2008 09:43 PM
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
populate one list box with selected values from another list box ASP .Net 1 03-12-2005 11:29 PM
compile C programs with UNIX system calls (= Unix Programs??) C++ 12 01-10-2005 03:35 AM