0

I am attempting to execute a unix "df -k" command in java. I have the following example.. My question is how do I parse the results of the command in order to grab the available bytes versus just printing it out????

import java.io.*;

public class unixcmd
{
public static void main(String args[])
{
try
{
Process p=Runtime.getRuntime().exec("df -k");
p.waitFor();
BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=reader.readLine();
while(line!=null)
{
System.out.println(line);
line=reader.readLine();
how do I grab this information and put it into an array??
}

}
catch(IOException e1) {}
catch(InterruptedException e2) {}

System.out.println("Done");
}
}

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Ezzaral
0

Thank you. I was wondering that, but not sure if the df returned as tab delimited... so I am assuming it is??

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.