读取文件 java

来源:互联网 发布:商城网站数据库表设计 编辑:程序博客网 时间:2024/04/28 13:10
package com.hytc.www;import java.io.BufferedReader;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;import java.util.Scanner;public class Hello {public static void main(String[] args) {String fileName = "F:\\javaEEworkspace\\test2\\src\\com\\hytc\\www\\a.txt";String line;try {BufferedReader in = new BufferedReader(new FileReader(fileName));line = in.readLine();while(line!=null){System.out.println(line);line = in.readLine();}in.close();} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}

0 0
原创粉丝点击