java讀取本地檔案內容

來源:互聯網
上載者:User

標籤:

1、要在F盤下有一個叫test的橫條圖格式的檔案,

 

Java代碼  
  1. package test;  
  2.   
  3. import java.io.BufferedReader;  
  4. import java.io.File;  
  5. import java.io.FileReader;  
  6.   
  7. public class ReaderFile {  
  8.       
  9.     public static void main(String[] args) throws Exception {  
  10.           
  11.         String fileName = "F://test.txt";  
  12.         File file = new File(fileName);  
  13.           
  14.         if( !file.exists() ){  
  15.             System.out.println("file not exist");  
  16.         }  
  17.           
  18.         FileReader fileReader = new FileReader(file);  
  19.         BufferedReader bReader = new BufferedReader(fileReader);  
  20.           
  21.         String tempString = null;  
  22.         while ( (tempString = bReader.readLine()) != null ) {  
  23.             System.out.println(tempString);  
  24.         }  
  25.           
  26.         bReader.close();  
  27.         fileReader.close();  
  28.           
  29.     }  
  30.       
  31. }  
package test;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;public class ReaderFile {public static void main(String[] args) throws Exception {String fileName = "F://test.txt";File file = new File(fileName);if( !file.exists() ){System.out.println("file not exist");}FileReader fileReader = new FileReader(file);BufferedReader bReader = new BufferedReader(fileReader);String tempString = null;while ( (tempString = bReader.readLine()) != null ) {System.out.println(tempString);}bReader.close();fileReader.close();}}

 

java企業級通用許可權安全架構源碼 SpringMVC mybatis or hibernate+ehcache shiro druid bootstrap HTML5

【java架構源碼下載】

java讀取本地檔案內容

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.