String fileName = "test.txt"; File f = new File(fileName); long fileSize = f.length(); System.out.format("The size of the file: %d bytes", fileSize);