test/java/lang/Runtime/exec/WinCommand.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /* @test
  25  * @bug 5006520
  26  * @summary Check many different ways to run Windows programs
  27  * @author Martin Buchholz
  28  *
  29  * @compile -source 1.5 WinCommand.java
  30  * @run main WinCommand
  31  */
  32 
  33 import java.io.*;
  34 import java.util.*;
  35 import static java.lang.System.*;
  36 
  37 class StreamDrainer extends Thread {
  38     private final InputStream is;
  39     private final ByteArrayOutputStream os = new ByteArrayOutputStream();
  40     public StreamDrainer(InputStream is) { this.is = is; }
  41     public void run() {
  42         try {
  43             int i;
  44             while ((i = is.read()) >= 0)
  45                 os.write(i);
  46         } catch (Exception e) {}
  47     }
  48     public String toString() { return os.toString(); }
  49 }
  50 




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /* @test
  25  * @bug 5006520
  26  * @summary Check many different ways to run Windows programs
  27  * @author Martin Buchholz



  28  */
  29 
  30 import java.io.*;
  31 import java.util.*;
  32 import static java.lang.System.*;
  33 
  34 class StreamDrainer extends Thread {
  35     private final InputStream is;
  36     private final ByteArrayOutputStream os = new ByteArrayOutputStream();
  37     public StreamDrainer(InputStream is) { this.is = is; }
  38     public void run() {
  39         try {
  40             int i;
  41             while ((i = is.read()) >= 0)
  42                 os.write(i);
  43         } catch (Exception e) {}
  44     }
  45     public String toString() { return os.toString(); }
  46 }
  47