CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Jun 2015
    Posts
    21

    Problem writing from PrintStream to "Console as Process" ,not "console as System.out"

    in Java 8, windows 10, i have a text app, i want to open a console and write something there,

    first try is:

    Code:
        String [] cmd = {"cmd.exe", "/c", "start"};
        ProcessBuilder f = new ProcessBuilder(cmd);
        f.redirectErrorStream(true);
        Process p = f.start();
        PrintStream printStream=new PrintStream(p.getOutputStream());
        //
        System.setOut(printStream);
        System.out.println("this write in CMD"); //did not work
    second try is:

    Code:
        printStream.println("this write in CMD");//did not work
    Can any body Help?
    Last edited by alwaystudent; December 15th, 2021 at 01:04 PM.

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured