import java.io.*;
public class TT {
public float freeSpace() throws IOException{
// TODO Auto-generated method stub
String command = "cmd.exe /c dir e:";
Runtime runtime = Runtime.getRuntime();
Process process = null;
process = runtime.exec(command);
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
String freeSpace = null;
while ((line = in.readLine()) != null)
{
freeSpace = line;
}
process.destroy();
freeSpace = freeSpace.trim();
freeSpace = freeSpace.replaceAll("//.", "");
freeSpace = freeSpace.replaceAll(",", "");
String[] items = freeSpace.split(" ");
int index = 1;
float f = 1024*1024*1024;
while (index < items.length)
{
//System.out.println("dsfa");
try
{
long bytes = Long.parseLong(items[index++]);
System.out.println(bytes/f);
return bytes/f;
}catch (NumberFormatException nfe)
{ }
}
return -1;
}
public static void main(String[] args) throws IOException {
TT t = new TT();
System.out.println(t.freeSpace());
}
}