Results 1 to 3 of 3
  1. #1
    cooljava is offline Member
    Join Date
    Aug 2014
    Rep Power

    Default Can this possibly done?


    Say you have a program called "whatever.exe". Basically, what this program does is to run batch commands, "dir" and "cd".
    if you run this "whatever.exe", the output will be something like...
    blahblah. list of directories..
    cd blahblah..

    you want to run this "whatever.exe" from java application..
    So like..

    Runtime rt = Runtime.getRuntime();
    Process pr = rt.exec("whatever.exe");
    BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String line = null;
    while( (line = input.readLine() ) != null) {
    } are going to see the output result for the whatever.exe at your console...
    However, the thing I want is that..somehow..I want to intercept the cd command and change the parameter on the fly...
    For example, say, this whatever.exe runs "cd C:\ABCD" internally, but somehow I want to change this cd command like "cd C:\EFGH" to run by my Java application..
    Well..obviously, you don't have a source code for "whatever.exe".

    I was thinking if we somehow..somehow...could manipulate some stream...this could be done....but I really don't think though..
    Anyway, any idea would be appreciated.

    Last edited by cooljava; 08-08-2014 at 11:36 PM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Can this possibly done?

    What use would that be unless you already understand the purpose of "whatever.exe?" Why don't you explain
    what you are actually trying to accomplish? Then there might be an alternate way of achieving the same thing.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

Similar Threads

  1. Math.abs possibly returning a negative number
    By jdodle in forum New To Java
    Replies: 4
    Last Post: 10-06-2013, 02:31 AM
  2. Replies: 1
    Last Post: 08-18-2010, 11:53 AM
  3. this keyword possibly buggy with scopes ?
    By Coral in forum Advanced Java
    Replies: 4
    Last Post: 02-02-2010, 12:50 PM
  4. Replies: 6
    Last Post: 04-10-2009, 02:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts