2014-10-01 61 views

回答

0

我想你使用Maven。

將文件放入文件夾src/main/resources/<your special place>/myStyle.xslt

在您的應用程序,並在您的測試就可以了,那麼你可以參考它的「資源訪問由

// Get the Classloader to load the XSLT 
ClassLoader classloader = this.getClass().getClassLoader(); 
// Get th URL of the file 
URL url = classloader.getResource("<your special place>/myStyle.xslt"); 
// Now you can read it... 
InputStream in = url.openStream(); 
// ...or use it as a file 
// ATTATION: This works only if the file is not inside a a JAR, WAR etc. 
//   But it works inside your JUnit or TestNG tests and in an exploded WAR 
File file = new File(url.toURI()); 

希望幫助

相關問題