Java I/O 操作

Categories: Java February 1st, 2009 15:49

处理一个本地文件 或是一个InputStream

	public String parseEmail(String fileName) throws IOException{ 
		java.io.File file  = new java.io.File(fileName);
		if(file.isFile()) {
			return parseEmail(new FileInputStream(fileName));
		}else {
			throw new IOException();
		}
	}
	
	public String parseEmail(InputStream in) throws IOException{
		// InputStream in = new FileInputStream(fileName);
		InputStreamReader reader;
		
		reader = new InputStreamReader(in);
		
		BufferedReader br = new BufferedReader(reader);
		
		String data1;
		//按行读
		while((data1= br.readLine()) != null) {
		System.out.println(data1);
}
		

待续…

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.