sapete come si fa?
sapete come si fa?
in che senso ? in outputString di solito SCRIVI una stringa..
spiegati meglio..
odio chi parla di politica..
anzi vorrei fondare un partito contro tutto ciò
mi riferivo a una situazione del genere:
codice:ProcBuild p=new ProcBuild(); Runtime rt; rt = Runtime.getRuntime(); proc = rt.exec("mioEseguibile.exe"); OutputStream out=p.getOutputStream();
si appunto...Originariamente inviato da pcg4m3s
mi riferivo a una situazione del genere:
codice:ProcBuild p=new ProcBuild(); Runtime rt; rt = Runtime.getRuntime(); proc = rt.exec("mioEseguibile.exe"); OutputStream out=p.getOutputStream();
se vuoi leggere lo stream devi usare input, non output !!
codice:// FUNZIONE PER ESEGUIRE UN FILE .EXE O .BAT public int runFile(String pathfile){ int exitVal = 0; String errors = ""; try { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + pathfile); InputStream stderr = proc.getErrorStream(); InputStreamReader isr = new InputStreamReader(stderr); BufferedReader br = new BufferedReader(isr); String line = null; errors = errors + "Process exeFileName: " + pathfile + "\r\n"; while ( (line = br.readLine()) != null){ errors = errors + line + "\r\n"; } exitVal = proc.waitFor(); errors = errors + "Process exitValue: " + exitVal; } catch (Throwable t){ // SCRITTURA LOG System.out.println("JAVA ERROR " + t.getMessage()); exitVal = -1; } return exitVal; }
odio chi parla di politica..
anzi vorrei fondare un partito contro tutto ciò
ok. non è che conosci anche il modo di catturare, oltre agli output sul terminale, anche gli output prodotti da un eventuale programma su una finestra grafica?Originariamente inviato da morphy79
si appunto...
se vuoi leggere lo stream devi usare input, non output !!
codice:// FUNZIONE PER ESEGUIRE UN FILE .EXE O .BAT public int runFile(String pathfile){ int exitVal = 0; String errors = ""; try { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + pathfile); InputStream stderr = proc.getErrorStream(); InputStreamReader isr = new InputStreamReader(stderr); BufferedReader br = new BufferedReader(isr); String line = null; errors = errors + "Process exeFileName: " + pathfile + "\r\n"; while ( (line = br.readLine()) != null){ errors = errors + line + "\r\n"; } exitVal = proc.waitFor(); errors = errors + "Process exitValue: " + exitVal; } catch (Throwable t){ // SCRITTURA LOG System.out.println("JAVA ERROR " + t.getMessage()); exitVal = -1; } return exitVal; }
più di quello che ti ho dato non si può.. puoi solo catturare gli output dei programmi che esegui dal tuo programma java nel modo che ti ho indicato..
odio chi parla di politica..
anzi vorrei fondare un partito contro tutto ciò
Ti avevo fatto un esempio qui, cosa non ti è chiaro? :master:Originariamente inviato da pcg4m3s
sapete come si fa?
SpringSource Certified Spring Professional | Pivotal Certified Enterprise Integration Specialist
Di questo libro e degli altri (blog personale di recensioni libri) | NO M.P. TECNICI
Ne stai già parlando qui, e ti ho chiuso anche un'altra discussione in cui hai posto la stessa domanda.Originariamente inviato da pcg4m3s
ok. non è che conosci anche il modo di catturare, oltre agli output sul terminale, anche gli output prodotti da un eventuale programma su una finestra grafica?
Basta riproporre in altri thread, o in thread paralleli, domande poste in un'altra discussione.![]()
MARCO BREVEGLIERI
Software and Web Developer, Teacher and Consultant
Home | Blog | Delphi Podcast | Twitch | Altro...