Results 1 to 4 of 4
  1. #1
    killerf2006 is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default Included file throws error.

    Hi all,
    I'm new to java.

    I have a class which uses File Input stream to parse a file and I'm calling this class in another class. And in the second class I use JFileChooser to select the file and and I'm calling the first class with filelocation as parameter.

    But when I run it, it throws error that the filelocation "D:\t1.txt" is invalid and when i run the first class with the parameter "D:\\t1.txt", it runs perfectly.

    Can anyone help me in this.

    Thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,765
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by killerf2006 View Post
    Hi all,
    I'm new to java.

    I have a class which uses File Input stream to parse a file and I'm calling this class in another class. And in the second class I use JFileChooser to select the file and and I'm calling the first class with filelocation as parameter.

    But when I run it, it throws error that the filelocation "D:\t1.txt" is invalid and when i run the first class with the parameter "D:\\t1.txt", it runs perfectly.

    Can anyone help me in this.

    Thanks
    If you use one backslash '\' your first path is interpreted as "D:<tab>1.txt", which is clearly not what you had in mind.

    kind regards,

    Jos

  3. #3
    killerf2006 is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default

    Hi 1.txt"
    Thanks for the reply.
    But the string I got from the JFileChooser is like "D:\t1.txt".

    The program runs when I use "D:\\t1.txt". But when I use the string from JFilechooser It's not running.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,765
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by killerf2006 View Post
    Hi 1.txt"
    Thanks for the reply.
    But the string I got from the JFileChooser is like "D:\t1.txt".

    The program runs when I use "D:\\t1.txt". But when I use the string from JFilechooser It's not running.
    You have to show us some relevant code; we can't give more detailed replies without it. My guess is that the File object returned from the JFileChooser isn't used but just the name of the file (an obvious mistake)

    kind regards,

    Jos

Similar Threads

  1. throws exception
    By simorgh in forum New To Java
    Replies: 1
    Last Post: 07-30-2010, 01:24 AM
  2. Sending files though bluetooth (URL included) ???
    By agusCba in forum Sun Java Wireless Toolkit
    Replies: 2
    Last Post: 04-04-2010, 12:53 AM
  3. Execute() throws an NPE
    By mjz in forum JDBC
    Replies: 0
    Last Post: 08-06-2009, 03:25 AM
  4. throws
    By jdgallag in forum New To Java
    Replies: 14
    Last Post: 02-11-2009, 02:07 AM
  5. Exception throws when I read File
    By Juggler in forum New To Java
    Replies: 11
    Last Post: 08-18-2008, 07:09 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
  •