This article explains:
0. Since it's a basic magic, you're never going to talk about something pretty deep.
1. Not everyone likes to write, but as long as they can give themselves or others a little help, that ' s enough
2. Write only javase points (dynamic update, from the directory will see the updated content and time)
3. Welcome to the Groove and correction
4. Any reference to the predecessor of things, will definitely identify the source, if you accidentally made a mistake in the "source", please inform (here to apologize to you)
Directory:
0. Path issues in Java------2014/10/16
1.
Body:
1. Path issues in Java
Code description, as follows:
Packagecom.merlin.test;ImportJava.io.InputStream; Public classTest { Public Static voidMain (string[] args) {NewTest (). Testpath (); } Public voidTestpath () {//when using the getResourceAsStream () method, the root path refers to Classpath, which is the SRCInputStream In0 = This. GetClass (). getResourceAsStream ("/");//Note that the backslash is writtenSystem.out.println (IN0);//can read to the//not applicable when followed by path, is the class file pathInputStream in1 = This. GetClass (). getResourceAsStream ("A.xml");//Note that the backslash is writtenSystem.out.println (in1);//can read to theInputStream in2 = This. GetClass (). getResourceAsStream ("/b.xml");//Note that the backslash is writtenSystem.out.println (in2);//can read to theInputStream in3= This. GetClass (). getResourceAsStream ("/a.xml");//Note that the backslash is writtenSystem.out.println (in3);//cannot read }}
View Code
I love Java--java Love Me