FileInputStream 读取文件的绝对路径和相对路径

public class InOutDemo {

	public static void main(String[] args) throws Exception {
		System.out.println(new File(".").getAbsolutePath());
		InputStream is = new FileInputStream("g:\\1.txt");
		//InputStream is = new FileInputStream(".\\src\\cn\\linson\\io\\2.txt");
		//InputStream is = new FileInputStream(".\\config.properties");
		int len = 0;
		byte[] b = new byte[10];
		while((len = is.read(b))!= -1){
			for(byte bb:b){
				System.out.print((char)bb+" ");
			}
		}
	}
}


1,绝对路径

2,相对路径 2.txt在包下

3,config文件在工程根目录下

posted @ 2014-07-08 14:42  一路向北中  阅读(21532)  评论(0编辑  收藏  举报