導航:首頁 > 編程語言 > java列印路徑

java列印路徑

發布時間:2024-01-14 01:23:36

❶ Java 編寫一個程序 實現輸出一個給定目錄中的全部文件的路徑

讀取文件夾下所有文件及文件夾用.list()就可以,返迴文件名包括後綴名。
至於文件大小你試試這個:

public void File(String oldPath, String newPath) { //復制文件
//System.out.println(oldPath+"***"+newPath);
try {
//int bytesum = 0;
int byteread = 0;

InputStream inStream = new FileInputStream(oldPath); // 讀入原文件
FileOutputStream fs = new FileOutputStream(newPath);
byte[] buffer = new byte[1024]; //每次取用的大小
while ((byteread = inStream.read(buffer)) != -1) {
//bytesum += byteread; // 位元組數 文件大小
//System.out.println(bytesum);
fs.write(buffer, 0, byteread);
}
inStream.close();

}catch (Exception e) {
System.out.println(" file error");
e.printStackTrace();
}
}
把注釋去了,裡面的bytesum就是文件大小。

閱讀全文

與java列印路徑相關的資料

熱點內容
如何自己編譯android系統 瀏覽:786
phpmysqlpdomysqli 瀏覽:802
php修改sql語句 瀏覽:714
android有道api 瀏覽:381
撓耳營水表用的什麼app 瀏覽:49
戰錘40kpdf 瀏覽:375
java判斷字元串是漢字 瀏覽:462
2017初級教材pdf 瀏覽:451
松下空調壓縮機品牌 瀏覽:817
python復選框 瀏覽:747
反詐中心app是什麼時候出來的 瀏覽:586
魔獸世界需要什麼伺服器地址 瀏覽:189
啥是單片機休眠 瀏覽:104
什麼音樂app最好 瀏覽:929
牙膏自製解壓神器 瀏覽:329
卸載linuxwps 瀏覽:228
threadjavarunnable 瀏覽:360
一元線性回歸計演算法 瀏覽:950
刷寶app是什麼鬼 瀏覽:744
linux動態載入模塊 瀏覽:25