Results 1 to 12 of 12
  1. #1
    RichersooN is offline Senior Member
    Join Date
    Jan 2011
    Location
    Rizal Province, Philippiines
    Posts
    167
    Rep Power
    0

    Default JFileChooser Multiple selection how to get the canonical path of the each file select

    Hi I have a filechooser that can selected multiple files, I want to get the path of that file but when try to press ok button it has an error:
    Exception occurred during event dispatching:
    java.lang.NullPointerException
    at com.pxc.gui.FileChooser$2.actionPerformed(FileChoo ser.java:61)
    at javax.swing.JFileChooser.fireActionPerformed(Unkno wn Source)
    at javax.swing.JFileChooser.approveSelection(Unknown Source)
    at javax.swing.plaf.basic.BasicFileChooserUI$ApproveS electionAction.actionPerformed(Unknown Source)
    ...
    ...
    ...
    at com.pxc.gui.MyFrame.frameInitialization(MyFrame.ja va:58)
    at com.pxc.gui.FileChooser.<init>(FileChooser.java:84 )
    at com.pxc.gui.FileChooser.getFileChooserFiles(FileCh ooser.java:94)
    at com.pxc.process.LoadEEClocks$2.actionPerformed(Loa dEEClocks.java:66)
    Here is the code:
    Java Code:
    if (JFileChooser.APPROVE_SELECTION.equals(evt.getActionCommand())) {
    chooser.setMultiSelectionEnabled(true);
    File[] fileDir = chooser.getSelectedFiles(); 
    String[] fileDirString = null;
                            	
    for(int x=0; x<fileDir.length; x++){
    try {
    fileDirString[x] = fileDir[x].getCanonicalPath();
    System.out.println(fileDirString[x]);   
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }	                           	
    }
    dispose();
    }
    Please tell me how to get path of each selected file
    Last edited by RichersooN; 05-10-2012 at 05:23 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    RichersooN is offline Senior Member
    Join Date
    Jan 2011
    Location
    Rizal Province, Philippiines
    Posts
    167
    Rep Power
    0

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    I finally figured it out, thanks to you're criticizing @DarrylBurke instead of helping

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    Quote Originally Posted by RichersooN View Post
    I finally figured it out, thanks to you're criticizing @DarrylBurke instead of helping
    What planet are you on, son? On mine, giving suggestions that if followed help folks better understand your problem is called "helping", not "criticizing". Please show *exactly* where in Darryl's post there is any ounce of criticism? Which statement?

  5. #5
    RichersooN is offline Senior Member
    Join Date
    Jan 2011
    Location
    Rizal Province, Philippiines
    Posts
    167
    Rep Power
    0

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    Quote Originally Posted by Fubarable View Post
    What planet are you on, son? On mine, giving suggestions that if followed help folks better understand your problem is called "helping", not "criticizing". Please show *exactly* where in Darryl's post there is any ounce of criticism? Which statement?
    Is this can help my problem?

    Re: JFileChooser Multiple selection how to get the canonical path of the each file se
    To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

    db

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    Quote Originally Posted by RichersooN View Post
    Is this can help my problem?
    Edit: misunderstood your question above.

    Darryl's suggestion, if followed will help us better understand your problem and thereby be able to give you a decent answer. So yes, it is *very* helpful.

    How does it constitute "criticism"?
    Last edited by Fubarable; 05-11-2012 at 05:09 AM.

  7. #7
    RichersooN is offline Senior Member
    Join Date
    Jan 2011
    Location
    Rizal Province, Philippiines
    Posts
    167
    Rep Power
    0

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    how did he help?

  8. #8
    RichersooN is offline Senior Member
    Join Date
    Jan 2011
    Location
    Rizal Province, Philippiines
    Posts
    167
    Rep Power
    0

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    Quote Originally Posted by Fubarable View Post
    Edit: misunderstood your question above.

    Darryl's suggestion, if followed will help us better understand your problem and thereby be able to give you a decent answer. So yes, it is *very* helpful.

    How does it constitute "criticism"?
    how did he help?

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    Quote Originally Posted by RichersooN View Post
    how did he help?
    **Again** if you followed his suggestions and posted an SSCCE, **we** could better understand your problem and give you a decent answer. What don't you understand about this statement?

    **Again** how is it criticism?

  10. #10
    RichersooN is offline Senior Member
    Join Date
    Jan 2011
    Location
    Rizal Province, Philippiines
    Posts
    167
    Rep Power
    0

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    Quote Originally Posted by Fubarable View Post
    **Again** if you followed his suggestions and posted an SSCCE, **we** could better understand your problem and give you a decent answer. What don't you understand about this statement?

    **Again** how is it criticism?
    you criticize how i compose my thread.. what wrong with my post?? you're pointless

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    Quote Originally Posted by RichersooN View Post
    you criticize how i compose my thread.. what wrong with my post?? you're pointless
    I can pick out multiple threads in this forum where I've helped you plenty.

    I still don't understand your attitude toward's Darryl's post, why you mention it is criticizing you and how it doesn't help you, but I am through debating this, and with the attitude I am seeing you display here am through trying to help you in the future. I wish you luck.

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default Re: JFileChooser Multiple selection how to get the canonical path of the each file se

    This one's not worth trying to help. And yes, that is criticism.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. how can i get directory path without select any file ?
    By amr magdy in forum New To Java
    Replies: 1
    Last Post: 12-29-2011, 12:52 PM
  2. Replies: 4
    Last Post: 03-21-2011, 05:45 AM
  3. Replies: 8
    Last Post: 01-21-2010, 08:16 AM
  4. how to use JFileChooser to select file -> string
    By gezzel in forum AWT / Swing
    Replies: 15
    Last Post: 10-23-2008, 06:34 AM
  5. how to use JFileChooser to select file -> string
    By gezzel in forum New To Java
    Replies: 9
    Last Post: 09-18-2008, 10:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •