Problem using DOS program from java

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.

Advertisements

On Nov 11, 11:26 am, Noel <> 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.

Advertisements

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.

On Nov 11, 6:18 pm, Lars Enderin <> 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.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!