Intellij IDEA15:加载resources文件_System


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();
}
}

}