File size

Revision as of 14:51, 7 April 2007 by 70.83.182.253 (talk) (New page: {{task}} In this task, the job is to verify the size of a file called "input.txt". Assuming current directory or fullpath. Either "/input.txt" or "\input.txt". ==Java== [[Category:J...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In this task, the job is to verify the size of a file called "input.txt". Assuming current directory or fullpath. Either "/input.txt" or "\input.txt".

Task
File size
You are encouraged to solve this task according to the task description, using any language you may know.


Java

public class FileSizeTest {
   public static long getFileSize(String filename) {
       return new File(filename).length();
   }
   public static void test(String filename) {
       System.out.println("The following file called " + filename + 
           " has a file size of " + getFileSize(filename) + " bytes."
       );
   }
   public static void main(String args[]) {
        test("file", "input.txt");
        test("file", File.seperator + "input.txt");
   }
}