Q:

Write a Java program to find the size of a specified file

0

Write a Java program to find the size of a specified file
Sample Output:

/home/students/abc.txt  : 0 bytes                                      
/home/students/test.txt : 0 byte

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Scanner;
import java.io.File;
public class Exercise45 {

 public static void main(String[] args) {
  System.out.println("/home/students/abc.txt  : " + new File("abc.txt").length() + " bytes");
  System.out.println("/home/students/test.txt : " + new File("test.txt").length() + " bytes");
 }
}

Sample Output:

/home/students/abc.txt  : 0 bytes                                      
/home/students/test.txt : 0 bytes

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now