RPC/Plug-inプログラムのファイルを読み込む
753 ワード
public static String getFileAsString(String url) throws IOException {
return getFileAsString(url,Charset.forName("UTF-8"));
}
public static String getFileAsString(String url,Charset charset) throws IOException {
InputStream is = getFileInputStream(url);
StringBuffer sb = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = is.read(b)) != -1;) {
sb.append(new String(b, 0, n, Charset.forName("UTF-8")));
}
return sb.toString();
}
public static InputStream getFileInputStream(String url) throws IOException {
return Activator.getDefault().getBundle().getResource("config.html")
.openStream();
}