欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Java文件操作

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

 /**
  *
  * 先判斷文件是否存在,然后判斷文件是否為空。
  * 如果存在且不為空,則輸出文件內容在控制臺。
  *
  * @author rmouse_2005   
  * @data 2005-10-14  
  * @version 1.0
  */ 

public class Test {

 /**
  *
  * Test類(lèi)主函數
  *
  * @param args
  * @throws IO異常
  */
 public static void main(String[] args) throws IOException {
  String path = "h:\\eclipse\\test\\a.txt";
  Test t = new Test();
  if (t.isExist(path)) {
   if (t.isEmpty(path)) {
    System.out.println("success!");
    System.out.println();
    t.getValue(path);
   } else {

    System.out.println("false!");
   }
  } else {
   System.out.println("false!");
  }
 }

 /**
  *
  * 判斷文件是否存在
  *
  * @param file 文件名
  * @return 文件是否存在
  * true - 文件存在
  * false - 文件不存在
  */
 boolean isExist(String file) {
  File f = new File(file);
  if (f.exists()) {
   System.out.println("File is Exist!");
   return true;
  } else {
   System.out.println("File isn‘t Exist!");
   return false;
  }
 }

 /**
  *
  * 判斷文件是否為空
  *
  * @param file 文件名
  * @return 文件是否為空
  * true - 文件為空
  * false - 文件不為空
  * @throws IO異常
  */
 boolean isEmpty(String file) throws IOException {
  FileReader fr = new FileReader(file);
  if (fr.read() == -1) {
   System.out.println("File is Empty!");
   return false;
  } else {
   System.out.println("File isn‘t Empty!");
   return true;
  }
 }

 /**
  *
  * 讀取文件
  *
  * @param file 文件名
  * @throws IO異常
  */
 void getValue(String file) throws IOException {
  FileReader fr;
  fr = new FileReader(file);
  BufferedReader br = new BufferedReader(fr);
  String line = "";
  line = br.readLine();
  while (line != null) {
   String lineNew = "";
   lineNew = line;
   System.out.println(lineNew);
   line = br.readLine();
  }
 }
}

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
java中io操作小例子
Java文件操作詳解
文件數據的讀/寫(xiě)
java在指定路徑下創(chuàng )建文件,并寫(xiě)入文件內容
Java 2 實(shí)用教程(第5版)耿祥義版 習題十
java對本地日志文件的讀寫(xiě)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久