How to list files existing in a folder ??

hello
I want to lis all files that are existing in a folder
MaApp\myFolder\
note: myApplication is as executeable Jar file
I do somthing like that
File []fileList = (new File(this.getClass().getResource("/MyFolder/").getPath())).listFiles();
    for(int i=0; i < fileList.length; i++){
        String srcName = fileList.getName();
System.out.println("Filename: "+srcName);
// but java.lang.NullPointerException will be thrown
what is to do ????
thanks

that is not what I ned
so.
Mypp contain mor folders
myApp/Foder1
myApp/Folder2
myApp/Folder3/
in Folder3 are more files file1.txt, file2.txt,file3.txt,...
tol list the files wich exist in Folder3
  File []fileList = (new File("Folder3\\")).listFiles();
    for(int i=0; i < fileList.length; i++){
   }this works fine
but wenn I create an executeable jar of myApp
I becom an NullPointerException
becaus there is problem with the path new File("Folder3\\")
what I want how to let jar to know the path of hiles which are in Folder3
thanks

Similar Messages

  • In lr4 where/how to rename files if loaded from folder already on hard drive?

    Files imported from a card reader can be renamed upon import but where/how to rename files added from a folder already on the hard drive? Also, how to rename files so as to not have gaps in the number sequence once the "rejects" have been deleted? Thanks.

    Yes and yes.  And, using it with the new shoot name renamed the files perfectly! 
    There is even a "original number suffix" so if you don't like IMG_4501 and prefer DSC_4501 you can pull the 4501 (the suffix) and replace the first three characters.
    So, in one operation SFO-shoot-(IMG_4501).NEF could become Wine-country-shoot-(IMG_4501).NEF or even Wine-country-shoot-(4501).NEF if you prefer.  Powerful.
    Thank you Rikk and Adobe! Chris R

  • How Can I Make a Text File that Lists Files in a Finder Folder?

    I would like to email lists of files in my various Finder folders. I have Mac OS X (10.4.6). Finder works nicely, but I cannot figure out how to save a list of file names. Can I get advice? Thank you.

    I'd like to thank "roam" for the link http://www.searchwaresolutions.com which opened a site for "printwindow" for Mac OS. Wow!! That was easy! It's a free download for the standard product which luckily worked for me. After downloading PrintWindow, and putting it in my Applications and reading PDF instructions, I opened PrintWindow and clicked "File". Then I chose "Print Folder Listing", clicked that and see "Print Listing" of all my Mac's folders. Then, I selected the folder for which I wanted the file names listed on paper. Then it opens a Print Options menu. I clicked Print. Then, a "Page Setup" menu appears. I clicked "OK". Then a "Print" menu appears. On the "Print" menu, there is a PDF options menu!! On that, there is a "Save as PDF"!! I clicked "Save as PDF" and then there is a small "Save" menu where I typed a new file name and the folder in which I wanted the listing saved. It worked! Thank you.

  • How to detact if a file exist in a folder

    How can I detact a file (a jpg or flv) exists in a folder?
    The script that I can think of so far is like this,
    var filename:String= "videos/vid test 0110.flv";
    if (filename){
    trace("well done");
    }else{
    trace("sorry");
    Please help me on this problem if you know....
    Thanks.
    Lau

    Sorry I have to rephrase the word - detect - to "check",
    sounds more pricisely...
    How can I check a file (a jpg or flv) exists in a folder?
    for instance flash can check if there is an instance exist or
    not on the timeline, for example a movie clip is called myMovie_mc.
    if (myMovie_mc){
    trace("myMovie_mc exist");
    }else{
    trace("sorry myMovie_mc doesnot exist");
    This is checking the instance on the timeline... but what I
    need is the check if a file (a flv file) exists or not in a folder
    outside the fla file.
    If that flv does exist in that folder ("videos" I called it),
    then the flash will take some actions. if it does not exist, then
    flash will do something else, like gotoAndPlay("default Intro").
    It will be much appreciated if anyone of you can sort this
    problem out for me.

  • How to list files from .jar file in applet?

    I have created applet and export all files to .jar file.
    I use File.list() method in applet to list files from one directory and that works ok but if I try to do that from web browser it sends exception AccessDenied meaning that File.list() isn't allowed in browser.
    I know what's the problem but I don't know how to solve it.
    What I want is to read from directory list of files.
    Help anyone?

    I will post here my code so that can be seen what I want to do:
    import java.awt.BorderLayout;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URLClassLoader;
    import java.nio.charset.Charset;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.JTextPane;
    public class test extends JApplet {
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JTextPane jTextPane = null;
          * This is the xxx default constructor
         public test() {
              super();
          * This method initializes this
          * @return void
         public void init() {
              this.setSize(449, 317);
              this.setContentPane(getJContentPane());
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(new BorderLayout());
                   jContentPane.add(getJTextPane(), BorderLayout.CENTER);
              return jContentPane;
          * This method initializes jTextPane     
          * @return javax.swing.JTextPane     
         private JTextPane getJTextPane() {
              if (jTextPane == null) {
                   jTextPane = new JTextPane();
              return jTextPane;
         public void start(){
              File fileDir= new File("somedirectory");
              String strFiles[]= fileDir.list();
              String a="";
              for(int i =0;i<strFiles.length;i++){
                   a=a+strFiles;
              this.jTextPane.setText(a);
    Method init() is irelevant, it just adds JTextPane in applet.
    Method start() is relevant, it runs normaly when started from Eclipse but from browser it sends exception AccessDenied.

  • How to set file name and destination folder without user interaction

    how can I set the file name and destination folder to generate a pdf file like "c:\myfolder\document.pdf" in this folder automatically.
    Is there a tag in .joboptions ?
    Goal: User click print button. In the background a pdf will be generated in e.g. "C:\myfolder\document.pdf".
    that`s it.
    I know that the query dialog for save as can be turned off. But the file name depends on the application.
    Thanks for your help.
    TK

    Hello,
    Please post this  in  PI forums
    Regards, Anil

  • CS4 - How to list files in order in 'Files view'

    Hi,
    I have numerous websites but some of them do not list the folders/pages order in the file view.
    Normally I have the folders at the top followed by the pages as per screen shot 1.
    I have tried refreshing the folder but no joy and I have gone to the master folder with the website and listed the files as 'details' as per my ok websites but still does not work.
    Any suggestions please.
    Thank you.
    Steve
    Screen shot 1 - CORRECT
    Screen shot 2 - COMPLETE MESS

    That second one is likely correct, listing files alphabetically by size.
    Clicking the heading "Local Files" should fix it.
    EDIT: If you click the Expand button in the files tab, it will give you more headings you can sort your files by...
    Local Files (alphabetical), Size, Type, Modified (date) and Checked Out By are the default possibilities.

  • How to list files that are NOT in a .jar file?

    Is it possible to list files (resources, .gif/.jpg files, etc.) that are NOT included in the jar but are still to be considered part of the application somewhere in the jnlp-file?
    My applications requires lots of icons which I have put into .gif files. So far I kept them in individual files next to the .jar file and that worked fine.
    JWS now seems to support only stuff that is included in (a) .jar-file(s). That in itself woul not be much of a problem, however, when I include my .gif files into the .jar files they seem to get corrupted by the jar-signing process (at least that what's the code says, which can suddenly not handle these images any more).

    My previous seem to have been non-sense. The .gif file were not corrupted, but rather they were not found at all. They actually must NOT be included in the .jar file, or else they are not found. Strange enough, the .properties-file seemingly HAS to be in the .jar file to be found.
    This is something I'll probably never fully understand with java: which file-types it searches where...

  • How to check whether file exist in a folder at the application server

    Hi to all experts.
    if suppose there is a file at the application server test.txt my requirement if the one more file is created of the same name before overwriting the file a warning message is to displayed to the user that the file already exist .
    how to do it

    HI Mohammed,
    use The FM DX_FILE_EXISTENCE_CHECK
    or static class CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
    For more info
    search file in application server
    application server
    hope it helps you.
    Regards!

  • How to check file exist in applet?

    I would like to check the existance of a file from an applet. How can I achieve that? I'd tried many attempts but still fail to get an answer. Please kindly help.
    Below are my file structures:-
    folder/applet/myApplet.java
    folder/appletView.jsp
    folder/image/image1.gif
    I would like to check if image1.gif exist. if yes, then load and display it in applet, but I having problem on the how to specify the file location.

    Assuming image1 is in the same folder as the applet:
              InputStream is;
              byte[] buf = new byte[1024];
              URLConnection urlc = null;
              try {
                   URL a = new URL(this.getCodeBase(),"image1.gif");
                   urlc = a.openConnection();
                   is = urlc.getInputStream();
                   int len = 0;
                   ByteArrayOutputStream bos = new ByteArrayOutputStream();
                   while ((len = is.read(buf)) > 0) {
                        bos.write(buf, 0, len);
                   // close the inputstream
                   is.close();
              } catch (IOException e) {
                   try {
    // image1.gif probably does not exist
                        // now failing to read the inputstream does not mean the server did not send
                        // any data, here is how you can read that data, this is needed for the same
                        // reason mentioned above.
                        ((HttpURLConnection) urlc).getResponseCode();
                        InputStream es = ((HttpURLConnection) urlc).getErrorStream();
                        int ret = 0;
                        // read the response body
                        while ((ret = es.read(buf)) > 0) {
                        // close the errorstream
                        es.close();
                   } catch (IOException ex) {
                        // deal with the exception
              }

  • HT201737 how to move files into a finder folder

    how do I move files into an existing folder in finder on MacBook Pro?

    I am attempting to move some EXEL files that have been saved as documents.  When I open finder, these files do not appear in the recent, or last 30 days section so I need to search fro them.  When they are found they are not on the page where the folder exists so I don't seem to be able to drag them to the folder. 

  • Single Click to Download File - Auto Rename if Conflicting File Exists in Downloads Folder

    I am trying to migrate from Safari. However, one of THE most important features that I simply can't do without, is the one click "Download Linked File" right click contextual menu item. This together with the auto-rename file action if a name conflict exists within the downloads folder, to which you are saving the file.
    Is there a way to do this in FF? All I can locate is"Save Link As" and then you have to either click to save or manually rename the file if there is a conflict. This is a real pain - I am happy to allow duplicate filenames for certain files.
    Hopefully someone can point me in the right direction - needs to be an absolute one click solution from contextual menu via an add on or something.
    Thanks

    As I recall, DownThemAll is able to do this. You first have to configure it to rename files when a file with the same name already exists. Then you should be able to use the context menu option labeled “DTA OneClick!” or some such.
    * https://addons.mozilla.org/firefox/addon/downthemall/

  • How to upload files residing in a folder on local file system .

    Hi, I have a problem when trying to upload files.
    I have a folder in my local system and have n files in it. Now if i use the file upload element i need to click n times to upload these files. So i want to achieve programatically to upload all the files in a folder given the folder name to the application. Is this possible or is there any restriction to achieve this through webdynpro.
    Also how to know programatically all the names of files and folders in a particular folder during web dynpro session.
    Regards,
    Vinay.

    Hi Vinayaka,
    Watch these links..
    Uploading multiple files using the FileUpload UI element
    Files...
    Regards,
    Karthick K Eswaran
    Display files in web browser

  • When the webhelp folder is hosted, an error message is displayed, "whproxy.js file is missing", though the file exists in the folder.

    I have recently updated my project file with DUCC concept using the trial version of Robohelp 10. After generating the project, I have submitted the webhelp for hosting. When the concerned person tried to host the webhelp folder to the server, it is indicating that the whproxy.js file is missing, though it exists in the hosted webhelp folder.
    Please help me out with this.

    Does the help work when you open it locally? If it does, something is wrong with the upload progress or the server configuration. If it doesn't, try generating your output again.
    Kind regards,
    Willam

  • How to List files in a directory into an Array

    Does anyone know of the best way to load all of the files in a specified directory into an array. (not going into sub directories either).
    I was to be able to do something like this.... (pseudo)
    String directory = "C:\";
    String [] theList;
    do
    get next file name;
    add to theList;
    }while(!End of Directory)
    Done.

        public static void main(String args[]) {
         String directory = "C:\\";
         File dir = new File(directory);
         File [] theList = dir.listFiles();
         for(File file : theList)
             if(!file.isDirectory() && !file.isFile())
              System.out.println(file.getName());
         }This will list every item in the coot of C:\ that is not a file or a directory. Change the if statement to fit your needs.
    ~Tim

Maybe you are looking for