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文件在工程根目录下


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM