Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: My path is changed...

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default My path is changed...

    Hi there,
    I created a form with NetBeans. The client lets the user choose two files.
    There's a text box that saves the full path of the files' locations.
    Only when I browse for the files and add them to the project, the paths written in the text boxes are not the paths where the file are located.
    i.e. the path is "C:\\Documents and Settings\\All Users\\Desktop\\test\\file_name.txt", the text box line is:
    "C:\\Documents and Settings\\All Users\\My Documents\\NetBeansProjects\\Test\\file_name.txt"
    where "C:\\Documents and Settings\\All Users\\My Documents\\NetBeansProjects\\Test\\" is the project folder.

    I tried to use
    textbox1.setText(txtFile.getAbsolutePath());
    and
    [highlight = Java]
    textbox1.setText(txtFile.getCanonicalPath());
    [/highlight]

    but both showed the same results.

    Of course, when I tried to read the files, I got the "File Not Found" error.

    Can any please tell me why this is happening?

    Regards,
    Oryan


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: My path is changed...

    Your wrapping paths are hard to read. Start each on a new line so they are in column:

    when I browse for the files and add them to the project, the paths written in the text boxes are not the paths where the file are located. i.e. the path is
    "C:\\Documents and Settings\\All Users\\Desktop\\test\\file_name.txt",
    the text box line is:
    "C:\\Documents and Settings\\All Users\\My Documents\\NetBeansProjects\\Test\\file_name.txt"
    where
    "C:\\Documents and Settings\\All Users\\My Documents\\NetBeansProjects\\Test\\" is the project folder.

    How are the Paths being put into the text areas? Copy and paste? Assignment from a method in JFileChooser? By the IDE?

Similar Threads

  1. Relative path issue with Context path struts
    By chinnu in forum Web Frameworks
    Replies: 1
    Last Post: March 31st, 2011, 10:17 AM
  2. Exception in jpcap path
    By vrp in forum Exceptions
    Replies: 0
    Last Post: February 10th, 2011, 12:04 AM
  3. What must be changed in the following code
    By kulk_dm in forum Member Introductions
    Replies: 2
    Last Post: February 3rd, 2011, 02:34 AM
  4. how to get full path name from realtive path
    By priyanka3006 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: August 10th, 2009, 04:28 AM
  5. [SOLVED] How to a set java class path?
    By captjade in forum Java Theory & Questions
    Replies: 1
    Last Post: March 10th, 2009, 06:40 AM

Tags for this Thread