1.从src目录下,读取文本文件内容
public static String inputStreamToString(Class _class, String metadataFileName) throws IOException {
InputStream in = _class.getResourceAsStream(metadataFileName);
StringBuffer out = new StringBuffer();}
2.从src目录下,读取icon
public static byte[] getIconData(Class clazz, String file) {
try {
InputStream input = clazz.getResourceAsStream(file);
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
}
return output.toByteArray();
} catch (IOException err) {
err.printStackTrace();
}
return null;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/sweiqin/article/details/48047927