Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从c++;在java中不返回 我正在研究java Swing,为C++编程制作GUI。我需要C++程序在一个循环中执行而不返回java。在这个循环过程中,我希望捕获一些输出,而无需单步执行 返回0;在C++程序中< /P> 我能从C++文件中获取输出而不返回java gui吗? 这是我的代码中的出和入过程 try { int out = 0; String line; OutputStream stdin = null; InputStream stderr = null; InputStream stdout = null; // calling the exe file Process process = new ProcessBuilder("unpattern.exe").start(); stdin = process.getOutputStream(); stderr = process.getErrorStream(); stdout = process.getInputStream(); // input process // "write" the parms into stdin line = "1"; stdin.write(line.getBytes()); stdin.flush(); //line = "tx.getText()" + "\n"; // stdin.write(line.getBytes()); // stdin.flush(); stdin.close(); // output process // clean up if any output in stdout BufferedReader brCleanUp = new BufferedReader(new InputStreamReader(stdout)); while ((line = brCleanUp.readLine()) != null) { // counter of the defects System.out.println(line); } catch (IOException ex) { Logger.getLogger(QeyeGui3.class.getName()).log(Level.SEVERE, null, ex); }_Java_C++_Swing_User Interface - Fatal编程技术网

从c++;在java中不返回 我正在研究java Swing,为C++编程制作GUI。我需要C++程序在一个循环中执行而不返回java。在这个循环过程中,我希望捕获一些输出,而无需单步执行 返回0;在C++程序中< /P> 我能从C++文件中获取输出而不返回java gui吗? 这是我的代码中的出和入过程 try { int out = 0; String line; OutputStream stdin = null; InputStream stderr = null; InputStream stdout = null; // calling the exe file Process process = new ProcessBuilder("unpattern.exe").start(); stdin = process.getOutputStream(); stderr = process.getErrorStream(); stdout = process.getInputStream(); // input process // "write" the parms into stdin line = "1"; stdin.write(line.getBytes()); stdin.flush(); //line = "tx.getText()" + "\n"; // stdin.write(line.getBytes()); // stdin.flush(); stdin.close(); // output process // clean up if any output in stdout BufferedReader brCleanUp = new BufferedReader(new InputStreamReader(stdout)); while ((line = brCleanUp.readLine()) != null) { // counter of the defects System.out.println(line); } catch (IOException ex) { Logger.getLogger(QeyeGui3.class.getName()).log(Level.SEVERE, null, ex); }

从c++;在java中不返回 我正在研究java Swing,为C++编程制作GUI。我需要C++程序在一个循环中执行而不返回java。在这个循环过程中,我希望捕获一些输出,而无需单步执行 返回0;在C++程序中< /P> 我能从C++文件中获取输出而不返回java gui吗? 这是我的代码中的出和入过程 try { int out = 0; String line; OutputStream stdin = null; InputStream stderr = null; InputStream stdout = null; // calling the exe file Process process = new ProcessBuilder("unpattern.exe").start(); stdin = process.getOutputStream(); stderr = process.getErrorStream(); stdout = process.getInputStream(); // input process // "write" the parms into stdin line = "1"; stdin.write(line.getBytes()); stdin.flush(); //line = "tx.getText()" + "\n"; // stdin.write(line.getBytes()); // stdin.flush(); stdin.close(); // output process // clean up if any output in stdout BufferedReader brCleanUp = new BufferedReader(new InputStreamReader(stdout)); while ((line = brCleanUp.readLine()) != null) { // counter of the defects System.out.println(line); } catch (IOException ex) { Logger.getLogger(QeyeGui3.class.getName()).log(Level.SEVERE, null, ex); },java,c++,swing,user-interface,Java,C++,Swing,User Interface,while循环缺少右大括号: // .... while ((line = brCleanUp.readLine()) != null) { // counter of the defects System.out.println(line); // **** it should go here } 我建议您在while循环中不断获取传递到Bu

while循环缺少右大括号:

            // ....
            while ((line = brCleanUp.readLine()) != null) {
                // counter of the defects
                System.out.println(line);
            // **** it should go here
        }

我建议您在while循环中不断获取传递到BufferedReader的文本。如果您是在Swing应用程序的SwingWorker中执行此操作,则可以使用发布/处理方法对使用传输的信息更新Swing GUI。

您的while循环缺少右括号:

            // ....
            while ((line = brCleanUp.readLine()) != null) {
                // counter of the defects
                System.out.println(line);
            // **** it should go here
        }

我建议您在while循环中不断获取传递到BufferedReader的文本。如果您是在Swing应用程序的SwingWorker中执行此操作,那么您可以使用发布/处理方法对使用传输的信息更新Swing GUI。

我可以在这个链接中找到适合我的问题的解决方案 我在string builder中添加了缓冲区,这样我就可以使用它:)
感谢您的帮助:)

我可以在这个链接中找到解决问题的合适方法 我在string builder中添加了缓冲区,这样我就可以使用它:)
谢谢你的帮助:

但是即使在BufferedReader内部循环,java中的GUI仍然在C++中等待返回命令。我以前不使用SwingWorker,因为它对我的情况有用吗?@sohasamy:不要在循环中“生成”BufferedReader,但一定要在循环中读取它。当然,你需要一个背景线程,否则Swing会冻结。最简单、最安全的方法是使用SwingWorker。我可以在这个链接中找到解决问题的合适方法捕获DOS(命令提示符)的输出并在JAVA框架中显示我在string builder中添加了缓冲区,这样我就可以做到:)谢谢你的帮助:)但是即使在循环中创建了BufferedReader,java中的GUI仍然在C++中等待返回命令。我以前不使用SwingWorker,因为它对我的情况有用吗?@sohasamy:不要在循环中“生成”BufferedReader,但一定要在循环中读取它。当然,你需要一个背景线程,否则Swing会冻结。最简单、最安全的方法是使用SwingWorker。我可以在这个链接中找到解决问题的合适方法捕获DOS(命令提示符)的输出并在JAVA框架中显示我在string builder中添加了缓冲区,这样我就可以做到:)谢谢你的帮助:)