熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

java io讀取文本文件

2022-06-13   來源: Java核心技術 

  public class ReadSql {

  public static void readsql(String filePath) throws Exception{

  String encoding = gbk;

  File file = new File(filePath);

  if(fileisFile()&&fileexists()){

  InputStreamReader reader = new InputStreamReader(new FileInputStream(file)encoding);

  BufferedReader bufferedReader = new BufferedReader(reader);

  String line = null;

  while ((line = bufferedReaderreadLine())!=null) {

  Systemoutprintln(linetoString());

  }

  readerclose();

  }

  }

  public static void main(String[] args) throws Exception {

  Systemoutprintln(=================================================);

  ReadSqlreadsql(c:/rrtxt);

  Systemoutprintln(=================================================);

  }

  }


From:http://tw.wingwit.com/Article/program/Java/hx/201311/26986.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.