この記事では、ディスクスペースを取得するための2つのコードを共有しています。参照してください。
コード1:
java.io.file; public class diskspacedetail {public static void main(string [] args){file diskpartition = new file( "c:"); long totalcapacity = diskpartition.getTotalspace(); long freepartitionspace = diskpatitions.getFationspace(); diskPartition.getUsableSpace(); system.out.println( "****サイズのメガバイト**** / n"); system.out.println( "合計Cパーティションサイズ:" + totalcapacity /(1024*1024) + "mb"); System.out.Out.Out: " + usable Pationis +" mb "); system.out.println(" free space: " + freepartitionspace /(1024*1024) +" mb "); system.out.println(" / n ****サイズのギガバイト**** / n "); system.out.println("合計cパーティションサイズ: " +合計合計gb "); system.out.println(" usable space: " + usablepatitionspace /(1024 *1024 *1024) +" gb "); system.out.println(" free space: " + freepartitionspace /(freepartitionspace /(1024 *1024 *1024) +" gb ");}}実行結果
コード2:
public class freediskspace {public static void main(string [] args){file file = new file( "c:"); long totalspace = file.getTotalspace(); long freespace = file.getFreespace(); long usedspace = totalspace -freespace -freespace; system.out.out.println "g"); system.out.println( "残りのスペースサイズ:" + freespace / 1024/1024 / 1024 /1024 /1024 + "g"); System.out.println( "使用済みスペースサイズ:" + usedspace / 1024 /1024 /1024 + "g");}}}}}結果:
要約します
ハハ、それはみんなを笑わせました。
上記は、Javaがディスクスペースを取得することに関するこの記事の2つのコード例の全体的な内容です。私はそれが誰にでも役立つことを願っています。欠点がある場合は、それを指摘するためにメッセージを残してください。このサイトへのご支援をありがとうございました!