Working on a InputStream which is constructed from String. Can someone help me with any predefined method to get the size of InputStream or String? I am using below method but its giving me fairly different size when I save my string into File. PS:- I need to perform a operation according to size before saving it to file. I need to process a fairly large data around 2GB in size.
public static float getSizeInGB(String data) {
float unit = 1024.0f;
float dataBytes = data.getBytes(StandardCharsets.UTF_8).length * 2;
if (data == null) {
return 0;
}
return dataBytes/ (unit * unit * unit);
}