-
IO with shell processes
I'm trying to write a java program that runs a system command (shell) and
send/receives data to/from that process. Here is an example:
BufferedReader data = new BufferedReader(new FileReader(DATAFILE));
Process p = Runtime.getRuntime().exec(COMMAND);
PrintWriter pOut = new PrintWriter(
new OutputStreamWriter(p.getOutputStream())
);
BufferedReader pIn = new BufferedReader(
new InputStreamReader(p.getInputStream())
);
String buf;
// send data to sub-process
while ((buf = data.readLine()) != null) { pOut.println(buf); }
// read data from sub-process and display on screen
while ((buf = pIn.readLine()) != null) { System.out.println(buf); }
This is working fine for up to some unknown amount of data being SENT to to
sub-process (I'm not having problems reading the data coming back from the
sub-process). But when I try to send a large amount of data to the
sub-process I get problems; like locking up, a portion of the data repeating
continuously, or the sub-process doesn't actually receive all of the data.
Your first thought might be to just open a socket to the sub-process, but it
doesn't have socket capabilities.
Any help would be appreciated.
Thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks