[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: locating local directory




hi bill
try this code snippet
-----------------------------------------------------------------------------------
package my.test;
import java.io.*;
import java.net.*;

public class test{
      public static void main(String args[]) throws Exception{
            URL url=ClassLoader.getSystemResource("my/test/testfile");
            InputStream in = url.openStream();
            byte buff[]=new byte[10];
            in.read(buff,0,10);
            System.out.println(new String(buff));
            in.close();
      }
}
-------------------------------------------------------------------------------------------
create a file in the directory my.test.testfile and type in some details of more than 10bytes.

Hope this helps.
-vikrant




From:  Bill Woodson <radman@usefulware.com> on 07/25/2002 12:44 PM

To:    List AJUG <ajug-members@ajug.org>
cc:

Subject:    locating local directory

Hi All,

How do I find the directory the class exists in?  I need to refer to a text
file in that location.

Thanks,
Bill