Hi everybody.
I'm facing some problem while executing the following program.......
import java.io.*;
public class InterpretProgram
{
public static
String readStream(InputStream stream)
{
String output = "";
try
{
BufferedReader input = new BufferedReader(new InputStreamReader(stream));
String temp = "";
while ((temp = input.readLine()) != null)
output += temp + "\n";
input.close();
}
catch (IOException ie)
{
}
return(output);
}
public static void main(String[] args)
{
try
{
Process p = Runtime.getRuntime().exec("cat>sample.txt");//is this possible.
System.out.println("Output: " + readStream(p.getInputStream()));
System.out.println("Errors: " + readStream(p.getErrorStream()));
}
catch (IOException ie)
{ }
}
}
If not how can i use exec() to execute the command cat>sample.txt
Thanks in advance