Requirement:- There is a requirement to capture the file size of files that are picked from file source.
Solution:- In this below code, change the filename location to the location where the file is placed:-
import java.io.File;
import java.io.*;
String fileName = "C:/Users/Desktop/test.txt";
File f = new File(fileName);
long fileSize = f.length();
context.put("FileSize", fileSize);
The file size will be displayed in the variable "FileSize". Also, this value will be shown in context info too.
Comments
0 comments
Article is closed for comments.