如何用 Java 開啟一個純文字檔案?
你可以使用 File 類訪問純文字。
示例
import java.io.File;
public class ReadFile {
public static void main(String[] args) {
File f = null;
String str = "data.txt";
try {
f = new File(str);
boolean bool = f.canExecute();
String a = f.getAbsolutePath();
System.out.print(a);
System.out.println(" is executable: "+ bool);
} catch (Exception e) {
e.printStackTrace();
}
}
}輸出
C:\Users\data is executable: true
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP