Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [java]stringa di ritorno da eseguibile esterno

    allora ho bisogno di una mano..
    ho un eseguibile che come risultato mi restituisce una stringa.. cioè se lo lancio da dos il risultato è una stringa con delle parole, come posso catturare le stringhe?

    per ora ho questo per lanciare il file

    codice:
    import java.lang.Runtime;
    import java.io.IOException;
    
    public class fromExe {
    
    	public static void main (String args[]) {
    	    Runtime r = java.lang.Runtime.getRuntime();
    
    	    try {
    	      String[] strArray = new String[1];
    	      strArray[0]="C:\\file.exe"; 
    	      Process p = r.exec (strArray); 
    	    }
    	    catch (IOException e) {
    	      System.err.println ("Error on exec method call.");
    	      System.exit(1);
    	    }
    
    	    System.exit(0);
    	  }
    
    	}
    if u think u'r too small to make a difference, try sleeping with a mosquito!!

    Giochi a calcetto? Vuoi prenotare online il tuo campo preferito?

  2. #2
    hmm la scorciatoia sarebbe..

    file.exe>testo.txt e leggere il testo.. (funza in dos.. ora non riesco a farlo andare però) :/
    if u think u'r too small to make a difference, try sleeping with a mosquito!!

    Giochi a calcetto? Vuoi prenotare online il tuo campo preferito?

  3. #3
    ok risolto..

    codice:
    public class fileExe {
    
    	public static void main (String args[]) {
    
    	    try {
    	    	String line;
    	    	Runtime rt = Runtime.getRuntime();
    	        Process p = rt.exec("C:\\file.exe");
    	        BufferedReader input =  new BufferedReader (new InputStreamReader(p.getInputStream()));
    	        
    	        while ((line = input.readLine()) != null) {
    	        	System.out.println(line);
    	          }
    
    	        input.close();
    
    	    }
    	    catch (IOException e) {
    	      System.err.println ("Error on exec method call.");
    	      System.exit(1);
    	    }
    	    
    	    System.exit(0);
    	
    	  }
    
    	}
    if u think u'r too small to make a difference, try sleeping with a mosquito!!

    Giochi a calcetto? Vuoi prenotare online il tuo campo preferito?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.