aktuelle.kurse/m411/docs/Daten-Uebungen-CodeBeispiele/ConnectionSample.java

34 lines
830 B
Java
Raw Normal View History

2021-08-06 18:08:13 +02:00
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class ConnectionSample {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
//word we want to search for:
String word = "apple";
//call web-service and get input stream result:
URL url = new URL("http://services.aonaware.com/" +
"DictService/DictService.asmx/Define?word="+ word);
URLConnection yc = url.openConnection();
//test and show result as String:
BufferedReader in = new BufferedReader
(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}