String dirPath = "D:/As Freelancer/Live Assignment/Manjula letter and Contents/31.Java Programming(Dec 30,2018)"; File dir = new File(dirPath); String[] files = dir.list(); if (files.length == 0) { System.out.println("The directory is empty"); } else { for (String aFile : files) { System.out.println(aFile); } } String arr[]={}; Project.main(arr); } void DiskSpaceDetails() { System.out.println("Welcome to Free Space Display Section"); File file = new File("c:"); long totalSpace = file.getTotalSpace(); //total disk space in bytes. long usableSpace = file.getUsableSpace(); ///unallocated / free disk space in bytes. long freeSpace = file.getFreeSpace(); //unallocated / free disk space in bytes. System.out.println(Long.toBinaryString(totalSpace)); System.out.println(Long.toBinaryString(usableSpace)); System.out.println(Long.toBinaryString(freeSpace)); String arr[]={}; Project.main(arr); } void DiscBlock() { System.out.println("Welcome to Display Disc Block Section"); System.out.println("File system roots returned by FileSystemView.getFileSystemView():"); FileSystemView fsv = FileSystemView.getFileSystemView(); File[] roots = fsv.getRoots(); for (int i = 0; i < roots.length; i++) { System.out.println("Root: " + roots[i]); } System.out.println("Home directory: " + fsv.getHomeDirectory()); System.out.println("File system roots returned by File.listRoots():"); File[] f = File.listRoots(); for (int i = 0; i < f.length; i++) { System.out.println("Drive: " + f[i]); System.out.println("Display name: " + fsv.getSystemDisplayName(f[i])); System.out.println("Is drive: " + fsv.isDrive(f[i]));
System.out.println("Is floppy: " + fsv.isFloppyDrive(f[i])); System.out.println("Readable: " + f[i].canRead()); System.out.println("Writable: " + f[i].canWrite()); System.out.println("Total space: " + f[i].getTotalSpace()); System.out.println("Usable space: " + f[i].getUsableSpace()); } String arr[]={}; Project.main(arr); } void SimToReal() { System.out.println("Welcome to Copy a file from Sim to Real Section"); try{ Path temp = Files.move (Paths.get("D:\\As Freelancer\\Live Assignment\\Manjula letter and Contents\\ 31.Java Programming(Dec 30,2018)\\File.txt"), Paths.get("D:\\As Freelancer\\Live Assignment\\Manjula letter and Contents\\ 31.Java Programming(Dec 30,2018)\\Work\\File1.txt")); if(temp != null) { System.out.println("File renamed and moved successfully"); } else { System.out.println("Failed to move the file"); } } catch(Exception e) { System.out.println("Problem in File System"); } String arr[]={}; Project.main(arr); } void RealToSim() { System.out.println("Welcome to Copy a file from Real to Sim Section"); try{ Path temp = Files.move (Paths.get("D:\\As Freelancer\\Live Assignment\\Manjula letter and Contents\\ 31.Java Programming(Dec 30,2018)\\Work\\File1.txt"), Paths.get("D:\\As Freelancer\\Live Assignment\\Manjula letter and Contents\\ 31.Java Programming(Dec 30,2018)\\File.txt")); if(temp != null) { System.out.println("File renamed and moved successfully"); } else
{ System.out.println("Failed to move the file"); } } catch(Exception e) { System.out.println("Problem in File System"); } String arr[]={}; Project.main(arr); } void DeteleFile() { System.out.println("Welcome to Delete File Section"); File file = new File("D:\\As Freelancer\\Live Assignment\\Manjula letter and Contents\\31.Java Programming(Dec 30,2018)\\Work\\File1.txt"); if(file.delete()) { System.out.println("File deleted successfully"); } else { System.out.println("Failed to delete the file"); } String arr[]={}; Project.main(arr); } public static void main(String[] args) { Project p=new Project(); Scanner sc=new Scanner(System.in); System.out.println("\nWelcome to File Management"); System.out.println("1. Display a file"); System.out.println("2. Display the file table"); System.out.println("3. Display the free space bitmap"); System.out.println("4. Display a disk block"); System.out.println("5. Copy a file from the simulation to a file on the real system"); System.out.println("6. Copy a file from the real system to a file in the simulation"); System.out.println("7. Delete a file"); System.out.println("8. Exit\n"); System.out.println("Please Enter your Choice: "); int ch=sc.nextInt(); if(ch==1) { p.DisplayFile(); }
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser