Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Disk Space

Hi Team

 

Using Talend Job i want to find out what is free disk space available in in PC

I cmd prompt  in have used the following command to get it dir c:\

When i execute the same in tsystem component i am getting the path of  Talend root directory

Is their any to find it out

Please help me a bit urgent

 

Thanks In advance

Saranya

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I always the tSystem quite cumbersome so only use it when I really have to. In this case, you can actually use a simple bit of Java to get this. Have a play around with the following code in a tJava to see how it works, then move it to a tJavaFlex to return the data in a row....

 

Imports

import java.text.NumberFormat;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.FileStore;
import java.nio.file.Path;
import java.io.IOException;

Code

NumberFormat nf = NumberFormat.getNumberInstance();
for (Path root : FileSystems.getDefault().getRootDirectories()) {

    System.out.print(root + ": ");
    try {
        FileStore store = Files.getFileStore(root);
        System.out.println("available=" + nf.format(store.getUsableSpace())
                            + ", total=" + nf.format(store.getTotalSpace()));
    } catch (IOException e) {
        System.out.println("error querying space: " + e.toString());
    }
}

FYI I borrowed this code from here (https://stackoverflow.com/questions/1051295/how-to-find-how-much-disk-space-is-left-using-java). In order to use it in a tJavaFlex, put the code up to the start of the for loop in the Start Code, the rest (apart from the last "}") in the Main Code and the last "}" in the End Code. You can return your disk space data in the Main Code section by creating columns to do this.

View solution in original post

1 Reply
Anonymous
Not applicable
Author

I always the tSystem quite cumbersome so only use it when I really have to. In this case, you can actually use a simple bit of Java to get this. Have a play around with the following code in a tJava to see how it works, then move it to a tJavaFlex to return the data in a row....

 

Imports

import java.text.NumberFormat;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.FileStore;
import java.nio.file.Path;
import java.io.IOException;

Code

NumberFormat nf = NumberFormat.getNumberInstance();
for (Path root : FileSystems.getDefault().getRootDirectories()) {

    System.out.print(root + ": ");
    try {
        FileStore store = Files.getFileStore(root);
        System.out.println("available=" + nf.format(store.getUsableSpace())
                            + ", total=" + nf.format(store.getTotalSpace()));
    } catch (IOException e) {
        System.out.println("error querying space: " + e.toString());
    }
}

FYI I borrowed this code from here (https://stackoverflow.com/questions/1051295/how-to-find-how-much-disk-space-is-left-using-java). In order to use it in a tJavaFlex, put the code up to the start of the for loop in the Start Code, the rest (apart from the last "}") in the Main Code and the last "}" in the End Code. You can return your disk space data in the Main Code section by creating columns to do this.