您的位置:首页 > 其它

Intellij IDEA15:加载resources文件

2016-06-17 15:02 337 查看


package com.donews.staticlog;

import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* Created by silentwolf on 2016/5/17.
*/
public class loadfile {

public static void main(String[] argv) {
try {
InputStream is=loadfile.class.getClassLoader().getResourceAsStream("data.txt");

BufferedInputStream bis = new BufferedInputStream(is);

byte[] arr = new byte[1024*8];

int len;

while((len=bis.read(arr))!=-1) {

System.out.println(new String(arr,"utf8"));

}
}catch (Exception e) {
e.printStackTrace();
}
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: