1:
BufferedReader reader = null;
URLClassLoader loader = (URLClassLoader)getClass().getClassLoader();
InputStream in = null;
URLConnection urlConnection = null;
urlConnection = loader.findResource(fileName).openConnection();
urlConnection.setUseCaches(false);
in = urlConnection.getInputStream();
读取文件内容:
InputStreamReader is = new InputStreamReader(in);
BufferedReader br = new BufferedReader(is);
String line = br.readLine();
while (null != line)
{
xmlStr.append(line).append("\r\n");
line = br.readLine();
}
return xmlStr.toString();
2:Properties prop = new Properties();
prop.load(InstanceHandler.class.getResource("/rest.properties").openStream());
取属性:prop.getProperty("createInstanceURL");