Click here to watch in Youtube :
https://www.youtube.com/watch?v=s_3cDuo3r2Q&list=UUhwKlOVR041tngjerWxVccw
import java.io.File; public class FileDemo { public static void main(String[] args) { File file = new File("D:/work/myfile.txt"); /* * Returns the length of the file denoted by this * abstract pathname. The return value is * unspecified if this pathname denotes a directory. * * Returns: The length, in bytes, of the file * denoted by this abstract pathname, or 0L if the * file does not exist. */ long length = file.length(); System.out.println("length = " + length); } }
length = 36Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_File_length_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_File_length_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/882ffbbbc9c8fbb765fb4869059bc3ee253ad31b/BasicJava/JavaIODemo_File_length_App/?at=master
See also:
No comments:
Post a Comment