Get total size of file in bytes
You can do that simple with Files.size(new File(filename).toPath())
.
You can use the length()
method on File
which returns the size in bytes.
You don't need FileInputStream to calculate file size, new File(path_to_file).length()
is enough. Or, if you insist, use fileinputstream.getChannel().size()
.