According to the Java and GCS (Google Cloud Storage) documentation, there is not a command that can be used to show the storage disk like the example you have with UNIX df.
Using java, you could write the following code to get the storage using these methods:
getTotalSpace(), getUsableSpace() and getFreeSpace()
It will depend on what kind of information you can get.
Code Example:
package example;
import java.io.File;
public class DiskSpaceDetail
{
public static void main(String[] args)
{
File file = new File("c:");
long totalSpace = file.getTotalSpace(); //total disk space in bytes.
long usableSpace = file.getUsableSpace(); ///unallocated / free disk space in bytes.
long freeSpace = file.getFreeSpace(); //unallocated / free disk space in bytes.
System.out.println(" === Partition Detail ===");
System.out.println(" === bytes ===");
System.out.println("Total size : " + totalSpace + " bytes");
System.out.println("Space free : " + usableSpace + " bytes");
System.out.println("Space free : " + freeSpace + " bytes");
System.out.println(" === mega bytes ===");
System.out.println("Total size : " + totalSpace /1024 /1024 + " mb");
System.out.println("Space free : " + usableSpace /1024 /1024 + " mb");
System.out.println("Space free : " + freeSpace /1024 /1024 + " mb");
}
}
Output Example:
=== Partition Detail ===
=== bytes ===
Total size : 52428795904 bytes Space free : 33677811712 bytes Space
free : 33677811712 bytes
=== mega bytes ===
Total size : 49999 mb Space free : 32117 mb Space free : 32117 mb
Note:
Both getFreeSpace() and getUsableSpace() methods return the same total free disk space of a given partition.
Here is the documentation I reviewed for your awareness:
https://www.baeldung.com/java-google-cloud-storage
https://developers.google.com/api-client-library/java