directory parse and directorypathname

Discussion in 'Java' started by harryos, Jul 9, 2008.

  1. harryos

    harryos Guest

    hi
    i want to use a function that takes a directory path name and prints
    listing of files in it.The user may enter windows or unix style path
    as input.

    i tried this

    public void directorylisting(String dirpath){
    java.util.List imglist=new java.util.ArrayList();
    final String ext=".jpg"
    File pgmdir=new File(pgmdirname);
    String[] children=pgmdir.list(new FilenameFilter(){
    public boolean accept(File f,String name){
    if(name.endsWith(ext))
    return true;
    else
    return false;

    }
    });

    System.out.println"children:"+children);
    for (String i : children){
    System.out.println(i);
    }

    }


    this works if i enter directory name as
    F:\\png\\galleryimages\\
    or
    F:/png/galleryimages/

    but i want the windows user to enter only
    F:\png\galleryimages\

    Do i have to take the string and process it before calling the
    function or is there any other way ?may be using FileSeparator or
    something?can someone advise?
    thanks
    harry
    harryos, Jul 9, 2008
    #1
    1. Advertising

  2. harryos

    Lew Guest

    harryos wrote:
    >> this works if i [sic] enter directory name as
    >> F:\\png\\galleryimages\\
    >> or
    >> F:/png/galleryimages/
    >>
    >> but i [sic] want the windows user to enter only
    >> F:\png\galleryimages\
    >>
    >> Do i [sic] have to take the string and process it before calling the
    >> function or is there any other way ?may be using FileSeparator or
    >> something?can someone advise?


    Why in the patio would you want to devastate a mistakenly extraneous file path?

    --
    Lew


    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "All the truely dogmatic religions have issued from the
    Kabbalah and return to it: everything scientific and
    grand in the religious dreams of the Illuminati, Jacob
    Boehme, Swedenborg, Saint-Martin, and others, is
    borrowed from Kabbalah, all the Masonic associations
    owe to it their secrets and their symbols."

    --- Sovereign Grand Commander Albert Pike 33°
    Morals and Dogma, page 744

    [Pike, the founder of KKK, was the leader of the U.S.
    Scottish Rite Masonry (who was called the
    "Sovereign Pontiff of Universal Freemasonry,"
    the "Prophet of Freemasonry" and the
    "greatest Freemason of the nineteenth century."),
    and one of the "high priests" of freemasonry.

    He became a Convicted War Criminal in a
    War Crimes Trial held after the Civil Wars end.
    Pike was found guilty of treason and jailed.
    He had fled to British Territory in Canada.

    Pike only returned to the U.S. after his hand picked
    Scottish Rite Succsessor James Richardon 33° got a pardon
    for him after making President Andrew Johnson a 33°
    Scottish Rite Mason in a ceremony held inside the
    White House itself!]
    Lew, Jul 9, 2008
    #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:
    19
    Views:
    1,126
    Daniel Vallstrom
    Mar 15, 2005
  2. jo3c
    Replies:
    1
    Views:
    437
    Tim Chase
    Jan 2, 2008
  3. Saurabh Purnaye
    Replies:
    2
    Views:
    138
    Robert Klemme
    Jan 19, 2008
  4. 7stud --

    optparse: parse v. parse! ??

    7stud --, Feb 20, 2008, in forum: Ruby
    Replies:
    3
    Views:
    185
    7stud --
    Feb 20, 2008
  5. lg
    Replies:
    3
    Views:
    302
    Tad McClellan
    Aug 9, 2007
Loading...

Share This Page