Results 1 to 8 of 8
  1. #1
    uhdam is offline Member
    Join Date
    Mar 2009
    Posts
    6
    Rep Power
    0

    Default Path Specification problem

    Hi...

    i have an xml file and from that i need to refer to the dtds...

    In my system the dtd path accepts only if it is set as
    "/c:/Documents and settings/.... "

    but by default it has to be set as "c:/documents and settings/..."

    And because of this when i get absolute path and assign the value for opening a file or saving a file it shows error and i couldnt get the needed output.

    How to resolve.... what has to be done and why is this so....

    The dtd definition file path is to be mentioned in xml file na. in the top of xml file where i need to specify the dtd file path if i give the path as

    "C:/Documents and settings/Uhdam/Prj/src/Parser/dtdefintion.dtd" it shows me error and specifies that it should be in the format as below

    "/C:/Documents and settings/Uhdam/Prj/src/Parser/dtdefintion.dtd"

    So when i use methodname.getAbsolutePath(); it returns an error because it wouldnt consider the / in front of drive name by default.

    What to do to make the system recognize without slash in front of drive name.

    Thank you..

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    So add the slash to it then
    Java Code:
    String path = '/' + getAbsolutePath();
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    uhdam is offline Member
    Join Date
    Mar 2009
    Posts
    6
    Rep Power
    0

    Default

    Hi..

    I tried that... it didnt work... it shows me error. i have to get/set the absolute path and assign it to filename....

    like

    File file=fc.getSelectedFile();
    filename = file.getAbsolutePath();


    now tell me how to rectify the slash problem.. Its a bit urgent...

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    806
    Rep Power
    6

    Default Try this out

    Hi,
    Just try this out whether it solves ur problem

    String fileName =f.getAbsolutePath();
    fileName="/"+fileName.replace("\\","/");
    System.out.println("/"+fileName);

    -Regards
    Ramya
    Ramya:cool:

  5. #5
    uhdam is offline Member
    Join Date
    Mar 2009
    Posts
    6
    Rep Power
    0

    Default

    Hi ramya...

    Thanks for your solution.... but i am facing another problem too. though i have a xmlfile it shows me null pointer exception...

    i donno why... this is an absurd question though...

    C:/Documents%20and%20Settings/Uhdam/Prj/src/xmldata/xmlinfo.xml
    java.lang.PointerException

    this error is shown only when the code executes. when compiling i get no error. What could be the problem.. Help me as soon as possible.. its a bit urgent please...

    Thank you

  6. #6
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    806
    Rep Power
    6

    Default

    Could u please send a code and error printed in the monitor if possible
    ?
    Ramya:cool:

  7. #7
    uhdam is offline Member
    Join Date
    Mar 2009
    Posts
    6
    Rep Power
    0

    Default

    the error i posted is only displayed... will try to post the code

  8. #8
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    806
    Rep Power
    6

    Default

    Generally NullPointerException is Run time one.
    whenever u are using try-catch block for debugging purpose u do like this 2 identify which part of code is having problem

    try
    {

    -----
    }
    catch(Exception ex)
    {

    ex.printStackTrace();
    }
    Ramya:cool:

Similar Threads

  1. [SOLVED] SVN project's build path problem
    By er_zhong in forum Eclipse
    Replies: 0
    Last Post: 04-14-2009, 04:03 PM
  2. Weird path problem when reading properties file
    By jerry_popperq in forum New To Java
    Replies: 0
    Last Post: 03-18-2009, 03:32 PM
  3. Replies: 8
    Last Post: 02-17-2009, 12:57 PM
  4. latest java class specification
    By underthesun in forum Advanced Java
    Replies: 1
    Last Post: 08-28-2008, 08:32 AM
  5. problem with PATH
    By creativehacker in forum New To Java
    Replies: 4
    Last Post: 07-11-2007, 02:54 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
  •