Results 1 to 3 of 3
  1. #1
    java_kick is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default How to read xml file located in local system using Java

    Hi,

    I have one XML file in my local system. I am trying to read it in my project using this.getClass().getClassLoader() .getResourceAsStream(path), where the path is absolute path. But i am getting null as input stream.

    So, Could somebody help how to read xml file using java?

    Thanks in Advance,

    Raju

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

    Default

    getResourceAsStream() uses a path relative to the current classpath. To get a general file, use java.io.File and the various input streams and readers in that package.

  3. #3
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    For files with absolute paths (rather than relative to the classpath), just use FileInputStream.

Similar Threads

  1. help to read .pst file through java
    By umadas in forum Advanced Java
    Replies: 2
    Last Post: 12-19-2010, 04:32 AM
  2. How to read Excel file with java
    By chetan-24 in forum New To Java
    Replies: 5
    Last Post: 04-22-2009, 05:11 PM
  3. How to open a file located in server from client side
    By Malathi in forum Web Frameworks
    Replies: 4
    Last Post: 04-20-2009, 09:10 PM
  4. System.in.read() confusion
    By ankurdh in forum New To Java
    Replies: 5
    Last Post: 01-08-2009, 08:28 AM
  5. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 AM

Posting Permissions

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