|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Junior Member
Iscritto dal: Jun 2011
Messaggi: 18
|
MAIN
Salve a tutti
Ho il seguente main: package client; import java.rmi.RemoteException; import javax.mail.internet.NewsAddress; import javax.sound.midi.MidiDevice.Info; import org.apache.axis2.AxisFault; import org.example.www.if1.*; public class SnodoSclient { public static void main(String[] args) { try { ServiceIF1Stub client= new ServiceIF1Stub("http://localhost:8080/axis2/services/ServiceIF1"); PrintToVideoIF1 print = new PrintToVideoIF1(); LeggiStringa str= new LeggiStringa(); print.PrintGetId(client); print.PrintGetAll(client); } catch (AxisFault e) { e.printStackTrace(); } } } Come puoi notare nel main vengono fatte due chiamate e due metodi: 1)PrintGetId 2)PrintGetAll Ora, mi chiedevo se era possibile inserire nel main un codice che mi consentiva di dire: System.out.println("Inserisci getId se vuoi eseguire PrintGetId e getAll se vuoi eseguire PrintGetAll") E a seconda del valore stampato inseriro dall'utente viene dato avvio al metodo PrintGetId o PrintGetAll. Io avevo pensato di scrivere il seguente MAIN public static void main(String[] args) { try { ServiceIF1Stub client= new ServiceIF1Stub("http://localhost:8080/axis2/services/ServiceIF1"); PrintToVideoIF1 print = new PrintToVideoIF1(); LeggiStringa str= new LeggiStringa(); System.out.println("Inserisci getId se vuoi eseguire PrintGetId e getAll se vuoi eseguire PrintGetAll") ; if (str.readString().equals("getId") ) print.PrintGetId(client); else if (str.readString().equals("getAll") ) print.PrintGetAll(client); else System.out.println("Richiesta non valida"); } catch (AxisFault e) { e.printStackTrace(); } } } Così facendo ho riscontrato i seguenti problemi: 1)quando scrivo nella console getId nn ho nessun problema mi parte subito il metodo PrintGetId(client); 2)x il metodo PrintGetId(client) getAll lo devo scrivere per due volte consecutive perchè quando lo scrivo per la prima volta premo invio nn succede nulla..riscrivo getAll e mi parte il metodo PrintGetId(client). Perchè????? Dove LeggiStringa è la classe che consente di leggere input da tastiera e che ho implementato così: package client; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class LeggiStringa { public String readString(){ String str= new String(); InputStreamReader reader = new InputStreamReader (System.in); BufferedReader myInput = new BufferedReader(reader); try { str = myInput.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; }}} Grazie in anticipo ciao ciao |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 13:07.



















