Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem using DOS program from java

Reply
Thread Tools

Problem using DOS program from java

 
 
Noel
Guest
Posts: n/a
 
      11-11-2008
Dear all

I was succesful in using a text tagging program from java and also
gather its output. However it only functions when I use it for small
files (3k), when I use it for slightly larger text files (8k) it does
not work. If I use the program directly from the command prompt it
works for files of any size.

The problem does not lie within the 'type' dos command, as my java
program still lists the big file.

Here is the code

Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("cmd /c type c:\\NLP\\EXAMPLES\\Text | c:\\NLP\
\bin\\nlp.cmd -show_tags");

InputStream inStd = pr.getInputStream();
InputStreamReader inStdR = new InputStreamReader(inStd);
BufferedReader bStd = new BufferedReader(inStdR);

String line=null;

while((line=bStd.readLine()) != null)
{
System.out.println(line);
}

Does anyone know why big files cannot be tagged from java, but can be
tagged from the command prompt.

Thanks
N
 
Reply With Quote
 
 
 
 
Pushkaraj
Guest
Posts: n/a
 
      11-11-2008
On Nov 11, 11:26*am, Noel <brincatn...@gmail.com> wrote:
> Dear all
>
> I was succesful in using a text tagging program from java and also
> gather its output. However it only functions when I use it for small
> files (3k), when I use it for slightly larger text files (8k) it does
> not work. If I use the program directly from the command prompt it
> works for files of any size.
>
> The problem does not lie within the 'type' dos command, as my java
> program still lists the big file.
>
> Here is the code
>
> Runtime rt = Runtime.getRuntime();
> Process pr = rt.exec("cmd /c type c:\\NLP\\EXAMPLES\\Text | c:\\NLP\
> \bin\\nlp.cmd -show_tags");
>
> InputStream inStd = pr.getInputStream();
> InputStreamReader inStdR = new InputStreamReader(inStd);
> BufferedReader bStd = new BufferedReader(inStdR);
>
> String line=null;
>
> while((line=bStd.readLine()) != null)
> {
> * * * * System.out.println(line);
>
> }
>
> Does anyone know why big files cannot be tagged from java, but can be
> tagged from the command prompt.
>
> Thanks
> N



It worked on my computer, with data file of 15Kb.
I used Process pr = rt.exec("cmd /c type c:\\delmelab\\a.txt | grep
';'"); here I am using grep of cygwin environment, may be the batch
script you are using causing the problem.

Will you able to share the script to try the same in our environment.
 
Reply With Quote
 
 
 
 
Lars Enderin
Guest
Posts: n/a
 
      11-11-2008
Pushkaraj wrote:

> It worked on my computer, with data file of 15Kb.
> I used Process pr = rt.exec("cmd /c type c:\\delmelab\\a.txt | grep
> ';'"); here I am using grep of cygwin environment, may be the batch
> script you are using causing the problem.
>
> Will you able to share the script to try the same in our environment.

You can use cygwin grep with ';' as first and the file path as second
argument. No need to use a pipe.
 
Reply With Quote
 
Pushkaraj
Guest
Posts: n/a
 
      11-11-2008
On Nov 11, 6:18*pm, Lars Enderin <lars.ende...@telia.com> wrote:
> Pushkaraj wrote:
> > It worked on my computer, with data file of 15Kb.
> > I used Process pr = rt.exec("cmd /c type c:\\delmelab\\a.txt | grep
> > ';'"); here I am using grep of cygwin environment, may be the batch
> > script you are using causing the problem.

>
> > Will you able to share the script to try the same in our environment.

>
> You can use cygwin grep with ';' as first and the file path as second
> argument. No need to use a pipe.


you are giving solution to my code, thanks for that.
Here with 'pipe in command' I was checking if there is any problem
with if we invoke it with java.
 
Reply With Quote
 
Noel
Guest
Posts: n/a
 
      11-11-2008
Hello All and thanks for your replies

The problem was that a deadlock was being created when the program was
waiting for one of the streams to empty and the stream is not being
emptied since it is waiting for something else.

It was solved by my teacher by creating two threads, one for the
InputStream and one for the ErrorStream which write their contents
indipendently from the main program.

Thanks again and have a nice day
N


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IOS DoS defense causes DoS to itself:) Igor Mamuziæ Cisco 2 05-19-2006 11:59 PM
[newbie]How to install python under DOS and is there any Wxpython can be installed under dos? john san Python 19 02-18-2005 12:05 PM
Invoking A DOS Program Through A "C" Program ~neil~ C Programming 7 09-28-2004 08:20 PM
Unable to run MS-DOS in Windows and DOS properties tabs missing Don Computer Support 5 02-11-2004 07:20 PM
Executing DOS (yes, DOS) program from within Python? Ben Fairbank Python 2 10-07-2003 08:51 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57