import javax.imageio.*; import java.awt.image.*; import java.awt.*; import java.security.NoSuchAlgorithmException; import java.security.MessageDigest; import java.lang.reflect.*; import java.net.*; import java.io.*; import javax.swing.*; import java.util.regex.*; import java.util.List; import java.util.zip.*; import java.util.*; public class main { public static void main(String[] args) throws Exception { String dirToList = "."; File d = new File(dirToList); if (d.isDirectory()) { for (File f : d.listFiles()) { boolean isDir = f.isDirectory(); String line = (isDir ? "D" : "F") + " " + f.getName(); if (!isDir) { long size = f.length(); String suffix = "B"; if (size >= 1024*1024) { size = (size+1024*1024-1) / (1024*1024); suffix = "MB"; } else if (size >= 1024) { size = (size+1024-1) / 1024; suffix = "KB"; } line += " (" + size + " " + suffix + ")"; } print(line); } } } static void print() { System.out.println(); } static void print(Object o) { System.out.println(o); } static void print(long i) { System.out.println(i); } }