printInfo(f, out);
}
public static void printInfo(File file, PrintWriter out)
throws IOException, FileSystemException {
FileDevice fd = new FileDevice(file, "r");
try {
final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
FatFileSystemType type = fSS.getFileSystemType(FatFileSystemType.ID);
FatFileSystem fs = new FatFileSystem(fd, false, type);
try {
BootSector bs = fs.getBootSector();
bs.read(fd);
out.println("OEM name " + bs.getOemName());
out.println("bytes/sector " + bs.getBytesPerSector());
out.println("sectors/cluster " + bs.getSectorsPerCluster());
out.println("#reserved sectors " + bs.getNrReservedSectors());
out.println("#fats " + bs.getNrFats());
out.println("#rootdir entries " + bs.getNrRootDirEntries());
out.println("#logical sectors " + bs.getNrLogicalSectors());
out.println("Medium descriptor 0x" + Integer.toHexString(bs.getMediumDescriptor()));
out.println("sectors/fat " + bs.getSectorsPerFat());
out.println("sectors/track " + bs.getSectorsPerTrack());
out.println("#heads " + bs.getNrHeads());
out.println("#hidden sectors " + bs.getNrHiddenSectors());
fs.getFat().printTo(out);
fs.getRootDir().printTo(out);
try {
FatDirectory dir =
(FatDirectory) fs.getRootEntry().getDirectory().getEntry("AAP")
.getDirectory();
dir.printTo(out);
} catch (FileNotFoundException ex) {
out.println("No AAP directory");
}
try {
FatDirectory dir =
(FatDirectory) fs.getRootEntry().getDirectory().getEntry("boot")
.getDirectory();
dir.printTo(out);
} catch (FileNotFoundException ex) {
out.println("No boot directory");
}
} finally {
// fd.stop();
fd.close();
}
} catch (NameNotFoundException e) {
throw new FileSystemException(e);
}
}