Getting Directory File list on Unix Box

Discussion in 'Java' started by TManners, Jul 21, 2004.

  1. TManners

    TManners Guest

    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);
    oCs.execute();
    int iRetVal=oCs.getInt(4);
    if (iRetVal>0)
    {
    //out.print(iRetVal);
    out.print("Import failed. Please contact System Administrator with
    a system code of ");
    out.print(iRetVal);
    }
    else
    {
    response.sendRedirect("main.jsp?importsuccess=1");
    }
    }
    TManners, Jul 21, 2004
    #1
    1. Advertising

  2. In article <>,
    (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
    > UNIX.


    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
    Phillip Mills, Jul 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    344
    Ray Booysen
    Mar 3, 2006
  2. Rishi  Dhupar

    File Scanning on a Unix Box

    Rishi Dhupar, Apr 1, 2005, in forum: Java
    Replies:
    4
    Views:
    618
    Nigel Wade
    Apr 4, 2005
  3. Gnarlodious
    Replies:
    4
    Views:
    17,553
    elizas
    May 5, 2010
  4. Replies:
    12
    Views:
    1,613
    Dave Thompson
    Jan 10, 2005
  5. Roedy Green
    Replies:
    1
    Views:
    390
    John W Kennedy
    Oct 30, 2008
Loading...

Share This Page