이 기사는 디스크 공간을 얻기위한 두 가지 코드를 공유합니다. 참조하십시오.
Code 1:
import java.io.file; public class diskspacedetail {public static void main (string [] args) {file diskPartition = new File ( "c :"); long totalcapacity = diskPartition.getTotalSpace (); long freepartitionspace = diskPartition.getFreespace (); long usablepationspace diskPartition.getUsableSpace (); System.out.println ( "**** Mega Bytes **** / n"); System.out.println ( "총 C 파티션 크기 :" + TotalCapacity / (1024*1024) + "MB"); System.out.println ( "Usable Parable :" + usablepationspace / (1024). MB "); System.out.println ("여유 공간 : " + freepartitionSpace / (1024*1024) +"MB "); System.out.println (" / n **** giga bytes **** / n "); System.out.println ("총 C 파트션 크기 : " + ottleccapacity / (1024*1024) +" + " gb "); System.out.println ("usable space : " + usablePatitionSpace / (1024 *1024 *1024) +"GB "); System.out.println ("자유 공간 : " + freepartitionspace / (1024 *1024 *1024) +"GB ");}}}}}}}}}.실행 결과
Code 2:
public class freediskSpace {public static void main (string [] args) {파일 파일 = 새 파일 ( "C :"); Long TotalSpace = file.getTotalSpace (); long freespace = file.getfreespace (); Long Usspace = totalSpace -freespace; system.out.println ( "총 공간 크기 :" + TotalsPace / 1024 / 1024 / 1024 / 10224 / 1024 / 1024 "g"); System.out.println ( "나머지 공간 크기 :" + 프리 스페이스 / 1024 / 1024 / 1024 / 1024 / 1024 + "g"); System.out.println ( "중고 공간 크기 :" + usedspace / 1024 / 1024 / 1024 + "g");}}}}}}.결과:
요약
하하, 그것은 모두를 웃게 만들었습니다.
위의 것은 Java가 디스크 공간을 얻는 것에 대한이 기사의 두 코드 예제의 전체 내용입니다. 모든 사람에게 도움이되기를 바랍니다. 단점이 있으면 메시지를 남겨 두십시오. 이 사이트를 지원해 주신 친구들에게 감사드립니다!