Type of Submission: Article Title: Watson Explorer REST API Tutorial #1 Subtitle: Java Programming. Keywords: WEX, WCA, analytics, Watson
|
|
- Winifred Nelson
- 6 years ago
- Views:
Transcription
1 Type of Submission: Article Title: Watson Explorer REST API Tutorial #1 Subtitle: Java Programming Keywords: WEX, WCA, analytics, Watson Prefix: Mr. Given: Kameron Middle: A. Family: Cole Suffix: Job Title: Watson L2 Support Engineer Bio: Kameron Cole has been involved with Watson Content Analytics technology, formerly known as TAKMI, for 10 years. Kameron has designed and implemented large-scale Watson Content Analytics Solutions all over the world. He holds the first United States Patent in this technology, including three additional patents. Company: IBM Watson Photo filename: Abstract: One of the most powerful offerings in the Watson Content Analytics middleware is its robust REST API. Requiring no runtime and no compilation, REST code can be integrated with any programming that has access to Hypertext Transfer Protocol, providing access to real-time Watson cognitive analytical analysis. This first article lays the REST foundation, and offers three Java options for processing results.
2 Watson Explorer REST API Tutorial #1 Java Programming Contents Introduction...4 Search API: /search...4 Search Single collection, sorted by date (most recent first)...5 Search on another collection, also sorted by date...6 Search on two collections at once, combined results ordered by date...7 FireFox RestClient...8 Admin API: /pear...8 Java Programming Choices for processing returned results: String atom JSON Extended json Example: Using the Admin API to retrieve Processing Engine Archives Appendix X: Java StringWriter() code sample xx Listing X: atom code sample xx Listing X: json code sample xx Listing X: json code sample xx... 23
3 Author Date Version Kameron Cole July 28, Vijai Gandikota Mamatha Nagaraju
4 Introduction Representational State Transfer (REST) has gained widespread acceptance across the Web a simpler alternative to SOAP- and Web Services Description Language (WSDL)-based Web services. Adoption of REST by mainstream Web 2.0 service providers including Yahoo, Google, and Facebook who have deprecated or passed on SOAP and WSDL-based interfaces The REST API consists of two categories of APIs: APIs for search and text mining tasks The Search REST API is available on a search application infrastructure and listens on the search application port, which by default is port 8393 if it's an embedded server install. name>:<search application port>/api/v10/ for the Search REST API APIs for administration tasks The Administrative REST API is available on index servers and uses the same port number as the administrative console, which by default is 8390 if it's an embedded server install. name>:<administrative console port>/api/v10/ for the Administrative REST API When WebSphere Application Server installation option is selected, the default port is 80 for both API sets. You can change these port numbers when you install the product. Search API: /search All queries for the /search REST API have the format: hostname:port/api/v10/search In all cases, you will need to signify a collection, and, of course, a query. Some other useful parameters include:
5 sortkey some parametric field to be used to sort the results pagesize this is actually the number of results you want returned output this would be with XML using atom formatting, or json. If absent, atom is assumed Search Single collection, sorted by date (most recent first) e&pagesize=4
6 Search on another collection, also sorted by date e&pagesize=4
7 Search on two collections at once, combined results ordered by date CollectionB&query=cancer& sortkey=date&pagesize=10
8 FireFox RestClient A very useful development tool for viewing formatted REST responses is the RestClient from Firefox: Once this plugin is installed, you can view nicely formatted results in your Firefox browser. The next examples will demonstrate the RestClient. Admin API: /pear For analytics and data mining applications, there are a number of APIs for working with Processing Engine Archives (.pear extension). They have the canonical form: name>:<administrative console port>/api/v10/admin name>:<administrative console port>/api/v20/admin As with all REST calls, XML and JSON are available as return types. You can specify "&output=application/xml" to get XML and "&output=application/json" to get a return value in JSON.
9 Important: for Amin 1.0 API calls you need the parameters &api_username=<username>&api_password=<password> For the Admin 1.0 API, we can get a list of installed pears with /pear?method=getlist&api_username=<username>&api_password=<password> For the Admin API v2.0, there are two steps required: 1) First we must get a token, which can be then stored, and reused throughout the session. This provides better security
10 name>:<administrative console port>/api/v20/admin/login?username=username&password=password 2) Now we can use this token to call the /pear API /system/parse/pear/list&securitytoken=<security token obtained above>
11 Java Programming Java programming of REST has the additional step of establishing the HTTP transport. This can be done by the use of the Apache HttPClient package. NOTE: THERE HAVE BEEN SIGNIFICANT CHANGES TO THIS PACKAGE RECENTLY. THE CODING EXAMPLES PRESENTED ARE FROM V4.3 To invoke the /search API, we create the URL: private static final String URL = " The HttpClient has change a great deal. This is the code to instantiate a client that will close after the method exits. CloseableHttpClient httpclient = HttpClients.createDefault(); The previous method methods have been replaced by corresponding Objects. HttpPost httppost = new HttpPost(URL);
12 To add parameters, we create a name-value pair List List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("collection", "CollectionA CollectionB")); nvps.add(new BasicNameValuePair("query", "cancer")); nvps.add(new BasicNameValuePair("sortKey", "date")); nvps.add(new BasicNameValuePair("pageSize", "4")); The basic parameters are the collection ID (this is not the collection name), and the query. We have added the sortkey of date and pagesize of 4. Recall that pagesize is the equivalent of count. With the list parameters the final URL is construction and executed as an entity, following the classic command pattern of the Gang of Four ("Design Patterns: Elements of Reusable Object-Oriented Software", by Gamma, Helm, Johnson, Vlissides). httppost.setentity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response = httpclient.execute(httppost); The entity is responsible for getting the content: HttpEntity entity = response.getentity(); At this point, we need to decide how we want to get the content, which can vary. Choices for processing returned results: String The simplest approach is to use a StringWriter to capture the entire response as a String. HttpEntity entity = response.getentity(); InputStream is = entity.getcontent(); StringWriter writer = new StringWriter(); IOUtils.copy(is, writer, "UTF-8"); String results = writer.tostring(); System.out.println(results); The only special thing is this code is the use of Apache Commons IOUtils The output is straightforward:
13 atom Since atom is the default response, we will show a simple way to capture the results in a meaningful way. We are using the Rome extensions for Java We begin by capturing the content as a SynFeed Object: HttpEntity entity = response.getentity(); InputStream is = entity.getcontent(); SyndFeed feed = null; InputSource source = new InputSource(is); SyndFeedInput input = new SyndFeedInput(); feed = input.build(source); We are going to do a little extra Java now. Although the REST APIs allows us to sort the results by parametric values JSON Search results can be returned using json technology. To get the results returned as json, you will need to add a parameter to the search string: output=application/json In the Java code we have been working on, it would be like this:
14 The basics units of json responses, in terms of Java, are JsonObjects, and JsonArrays. In the return string, JsonObject are within a curly brace, and arrays are within a square bracket: Continuing to use the HttpClient code as outlined above, we want to get the response body. However, the first line in the response will NOT be understood by the json utilities. This is because it is the Http status: try { String status = response.getstatusline().tostring(); System.out.println(response.getStatusLine()); Output: HTTP/ OK There is a special method in the HttClient API (EntityUtils) to get the body, without the status line, as a String: CloseableHttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getentity(); String bodyasstring = EntityUtils.toString(response.getEntity()); Once we have the body as a String, we can parse it with a JsonParser. This takes a basic java.io.reader as an argument, which reads the string: Reader reader = new StringReader(bodyAsString); JsonParser jr = Json.createParser(reader); This parser divides the json message into events (like a SAX xml parser). These are javax.json.stream.jsonparser.event Event event = null; The first event in the response is "es_apiresponse":{"es_evaluationtruncation":false,"es_querye valuationtime":1,"es_totalresults":30676,"es_totalresultstyp e":"estimated","es_numberofavailableresults":500,"es_numbero festimatedresults":30676,"es_query":[{"role":"request","sear chterms":"cancer"
15 We will find this first Event and stop on it: // Advance to "es_apiresponse" key while(jr.hasnext()) { event = jr.next(); if(event == Event.KEY_NAME && "es_apiresponse".equals(jr.getstring())) { event = jr.next(); Now we can print out all the values of the es_apiresponse object: // Output contents of "es_apiresponse" object while(event!= Event.END_OBJECT) { switch(event) { case KEY_NAME: { System.out.print(jr.getString()); System.out.print(" = "); case VALUE_FALSE: { System.out.println(false); case VALUE_NULL: { System.out.println("null"); case VALUE_NUMBER: { if(jr.isintegralnumber()) { System.out.println(jr.getInt()); else { System.out.println(jr.getBigDecimal()); case VALUE_STRING: { System.out.println(jr.getString()); case VALUE_TRUE: { System.out.println(true); default: { event = jr.next(); finally{system.out.println("eof"); The output looks like this:
16 es_evaluationtruncation = false es_queryevaluationtime = 0 es_totalresults = es_totalresultstype = estimated es_numberofavailableresults = 500 es_numberofestimatedresults = es_query = role = request searchterms = cancer EOF Extended json Example: Using the Admin API to retrieve Processing Engine Archives int pearlov = 0; values count // I am declaring an integer to keep a track of the list of while ((line = reader.readline())!= null) { // for each line returned by WCA System.out.println(line); // first I am printing the line for reference pearlov = pearlov + 1; // I am increasing the count JsonReader jsonreader = Json.createReader(new StringReader("{")); // I am creating a dummy JsonReader JsonObject json = jsonreader.readobject(); // I am creating a JsonObject [NOTE: Not JSONObject. The methods available are different in both] jsonreader = Json.createReader(new StringReader(line)); // Now I am reading in my line which is a response back from WCA for the list of pears // But WCA doesnt return multiple lines for each pear. It only gives back one json line. peararray = jsonreader.readarray(); // So I create an array (JsonArray peararray;) and read the array into it from the JsonReader object int len = peararray.size(); // I check the length of the array System.out.println("The array has size = " + len); // Then for each element in the array for(int i=0; i<len;i++){ JsonObject jsonobject = peararray.getjsonobject(i);
17 // I first create a JsonObject [Again note not JSONObject] String ID = jsonobject.getstring("id"); etc etc. // I get one of the elements in the row that I want. System.out.println(ID); // And then I print it. Or store it to the database finally{ This produces the following output: [{"ID":"PearId1","NLQConfigurationGroups":[],"classpath":null,"installDir":"\/g pfs\/bi\/wcadata\/data\/pearsupport\/pearid1","maincompdesc":"com.ibm.watson.wc a.wca35_enron_00_pear.xml","name":"enron35_01","type":null,{"id":"pearid2","nl QConfigurationGroups":[],"classpath":null,"installDir":"\/gpfs\/bi\/wcadata\/da ta\/pearsupport\/pearid2","maincompdesc":"com.ibm.watson.l2_pear.xml","name":"g ENE00","type":null,{"ID":"PearId3","NLQConfigurationGroups":[],"classpath":nul l,"installdir":"\/gpfs\/bi\/wcadata\/data\/pearsupport\/pearid3","maincompdesc" :"com.ibm.watson.l2_pear.xml","name":"gene01","type":null,{"id":"pearid4","nlq ConfigurationGroups":[],"classpath":null,"installDir":"\/gpfs\/bi\/wcadata\/dat a\/pearsupport\/pearid4","maincompdesc":"com.ibm.watson.l2_pear.xml","name":"cl oudgenomics2","type":null,{"id":"pearid5","nlqconfigurationgroups":[],"classpa th":null,"installdir":"\/gpfs\/bi\/wcadata\/data\/pearsupport\/pearid5","mainco mpdesc":"com.ibm.watson.l2_pear.xml","name":"cloudgenomics3","type":null] The array has size = 5 PearId1 PearId2 PearId3 PearId4 PearId5 Appendix X: Java StringWriter() code sample xx package com.ibm.watson.rest.search.ordered; import java.io.ioexception; import java.io.inputstream; import java.io.stringwriter; import java.util.arraylist; import java.util.iterator; import java.util.list; import java.util.treeset; import org.apache.commons.io.ioutils; import org.apache.http.httpentity; import org.apache.http.namevaluepair;
18 import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.closeablehttpresponse; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.closeablehttpclient; import org.apache.http.impl.client.httpclients; import org.apache.http.message.basicnamevaluepair; import org.apache.http.util.entityutils; import org.xml.sax.inputsource; import com.sun.syndication.feed.synd.syndfeed; import com.sun.syndication.io.syndfeedinput; public class OrderedSearchQueryString { private static final String URL = " /** args */ public static void main(string[] args) throws Exception { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httppost = new HttpPost(URL); List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("collection", "CollectionA CollectionB"));; nvps.add(new BasicNameValuePair("query", "cancer")); nvps.add(new BasicNameValuePair("sortKey", "date")); nvps.add(new BasicNameValuePair("pageSize", "4")); httppost.setentity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response = httpclient.execute(httppost); try { System.out.println(response.getStatusLine()); HttpEntity entity = response.getentity(); InputStream is = entity.getcontent(); StringWriter writer = new StringWriter(); IOUtils.copy(is, writer, "UTF-8"); String results = writer.tostring(); System.out.println(results); EntityUtils.consume(entity); finally { response.close(); private static void writeresults(inputstream is) { StringWriter writer = new StringWriter();
19 try { IOUtils.copy(is, writer, "UTF-8"); catch (IOException e) { // TODO Auto-generated catch block e.printstacktrace(); String results = writer.tostring(); System.out.println(results); Listing X: atom code sample xx package com.ibm.watson.rest.search.ordered; import java.io.ioexception; import java.io.inputstream; import java.io.stringwriter; import java.util.arraylist; import java.util.iterator; import java.util.list; import java.util.treeset; import org.apache.commons.io.ioutils; import org.apache.http.httpentity; import org.apache.http.namevaluepair; import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.closeablehttpresponse; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.closeablehttpclient; import org.apache.http.impl.client.httpclients; import org.apache.http.message.basicnamevaluepair; import org.apache.http.util.entityutils; import org.xml.sax.inputsource; import com.sun.syndication.feed.synd.syndfeed; import com.sun.syndication.io.syndfeedinput; public class OrderedSearchQueryATOM { private static final String URL = " /** args */ public static void main(string[] args) throws Exception {
20 CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httppost = new HttpPost(URL); List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("collection", " CollectionA CollectionB")); //nvps.add(new BasicNameValuePair("collection", "ncbi")); nvps.add(new BasicNameValuePair("query", "cancer")); nvps.add(new BasicNameValuePair("sortKey", "date")); nvps.add(new BasicNameValuePair("pageSize", "4")); httppost.setentity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response = httpclient.execute(httppost); try { System.out.println(response.getStatusLine()); HttpEntity entity = response.getentity(); InputStream is = entity.getcontent(); //Rome stuff for reading atom SyndFeed feed = null; TreeSet<String> tree = new TreeSet<String>(); Iterator<String> iterator = tree.iterator(); InputSource source = new InputSource(is); SyndFeedInput input = new SyndFeedInput(); feed = input.build(source); List entries = feed.getentries(); int ctr=0; while (ctr<entries.size()) { String value = entries.get(ctr).tostring(); tree.add(value); ctr++; System.out.println("Set: "+tree); // writeresults(is); EntityUtils.consume(entity); finally { response.close(); private static void writeresults(inputstream is) { StringWriter writer = new StringWriter(); try { IOUtils.copy(is, writer, "UTF-8"); catch (IOException e) { // TODO Auto-generated catch block e.printstacktrace();
21 String results = writer.tostring(); System.out.println(results); Listing X: json code sample xx package com.im.watson.rest.admin; import java.io.bufferedreader; import java.io.reader; import java.io.stringreader; import java.util.arraylist; import java.util.list; import javax.json.json; import javax.json.jsonarray; import javax.json.jsonobject; import javax.json.jsonreader; import javax.json.stream.jsonparser; import javax.json.stream.jsonparser.event; import org.apache.http.namevaluepair; import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.closeablehttpresponse; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.closeablehttpclient; import org.apache.http.impl.client.httpclients; import org.apache.http.message.basicnamevaluepair; import org.apache.http.util.entityutils; public class AdminPEARListJson { private static final String URL = " /** args */ public static void main(string[] args) throws Exception { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httppost = new HttpPost(URL); List <NameValuePair> nvps = new ArrayList <NameValuePair>();
22 nvps.add(new BasicNameValuePair("method", "getlist")); nvps.add(new BasicNameValuePair("api_username", "user")); nvps.add(new BasicNameValuePair("api_password", "password")); nvps.add(new BasicNameValuePair("output", "application/json")); httppost.setentity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response = httpclient.execute(httppost); //pear?method=getlist&api_username=<username>&api_password=<password> try { String status = response.getstatusline().tostring(); String bodyasstring = EntityUtils.toString(response.getEntity()); String line = ""; JsonArray peararray; BufferedReader reader = new BufferedReader(new StringReader(bodyAsString)); int pearlov = 0; reader.readline())!= null) { System.out.println(line); while ((line = pearlov = pearlov + 1; JsonReader jsonreader = Json.createReader(new StringReader("{")); JsonObject json = jsonreader.readobject(); jsonreader = Json.createReader(new StringReader(line)); peararray = jsonreader.readarray(); int len = peararray.size(); " + len); for(int i=0; i<len;i++){ System.out.println("The array has size = JsonObject jsonobject = peararray.getjsonobject(i);
23 String ID = jsonobject.getstring("id"); System.out.println(ID); finally{ Listing X: json code sample xx package com.ibm.watson.rest.search.ordered; import java.io.reader; import java.io.stringreader; import java.util.arraylist; import java.util.list; import javax.json.json; import javax.json.stream.jsonparser; import javax.json.stream.jsonparser.event; import org.apache.http.namevaluepair; import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.closeablehttpresponse; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.closeablehttpclient; import org.apache.http.impl.client.httpclients; import org.apache.http.message.basicnamevaluepair; import org.apache.http.util.entityutils; public class OrderedSearchQueryJSON { private static final String URL = " /** args */ public static void main(string[] args) throws Exception {
24 CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httppost = new HttpPost(URL); List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("collection", "CollectionA CollectionB")); nvps.add(new BasicNameValuePair("query", "cancer")); nvps.add(new BasicNameValuePair("sortKey", "date")); nvps.add(new BasicNameValuePair("pageSize", "4")); nvps.add(new BasicNameValuePair("output", "application/json")); httppost.setentity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response = httpclient.execute(httppost); try { // String status = response.getstatusline().tostring(); String bodyasstring = EntityUtils.toString(response.getEntity()); Reader reader = new StringReader(bodyAsString); JsonParser jr = Json.createParser(reader); Event event = null; // Advance to "es_apiresponse" key { while(jr.hasnext()) { event = jr.next(); if(event == Event.KEY_NAME && "es_result".equals(jr.getstring())) event = jr.next(); // Output contents of "es_apiresponse" object while(event!= Event.END_OBJECT) { switch(event) { case KEY_NAME: { System.out.print(jr.getString()); System.out.print(" = "); case VALUE_FALSE: { System.out.println(false); case VALUE_NULL: { System.out.println("null"); case VALUE_NUMBER: { if(jr.isintegralnumber()) {
25 System.out.println(jr.getInt()); else { System.out.println(jr.getBigDecimal()); case VALUE_STRING: { System.out.println(jr.getString()); case VALUE_TRUE: { System.out.println(true); default: { event = jr.next(); finally{system.out.println("eof");
API 2.0 API 2.0 : : : : : JAVA JAVA 2.2 :
API 2.0 API 2.0 : : : 1. 1.1 : : : JAVA 2. 2.1 : JAVA 2.2 : : JAVA 2.3 JAVA 2.4 JAVA 2.5 JAVA 2.6 JAVA 2.7 JAVA 2.8 () JAVA 2.9 ( or ) JAVA 2.10 ( or ), JAVA 3. 3.1 JAVA (JAVA) : https://api.simboss.com
More informationType of Submission: Article Title: Integrating UIMA Development into Watson Explorer Studio Subtitle: Fully utilizing the new Java Perspective
Type of Submission: Article Title: Integrating UIMA Development into Watson Explorer Studio Subtitle: Fully utilizing the new Java Perspective Keywords: UIMA, Watson Prefix: Given: Kameron Middle: Arthur
More informationSimple Data Source Crawler Plugin to Set the Document Title
Simple Data Source Crawler Plugin to Set the Document Title IBM Content Analytics 1 Contents Introduction... 4 Basic FS Crawler behavior.... 8 Using the Customizer Filter to Modify the title Field... 13
More informationMobile Development Lecture 9: Android & RESTFUL Services
Mobile Development Lecture 9: Android & RESTFUL Services Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Elgayyar.weebly.com What is a RESTFUL Web Service REST stands for REpresentational State Transfer. In
More information<uses-permission android:name="android.permission.internet" />
Listing Program : 1. Android Manifest.xml
More informationCoding Menggunakan software Eclipse: Mainactivity.java (coding untuk tampilan login): package com.bella.pengontrol_otomatis;
Coding Menggunakan software Eclipse: Mainactivity.java (coding untuk tampilan login): package com.bella.pengontrol_otomatis; import android.app.activity; import android.os.bundle; import android.os.countdowntimer;
More informationRESTful Examples. RESTful Examples 1 Apache 3 Jersey 5 JAX-RS 7 ApplicationConfig.java 7 HelloGregg.java 8
RESTful Examples RESTful Examples 1 Apache 3 Jersey 5 JAX-RS 7 ApplicationConfig.java 7 HelloGregg.java 8 REST in JavaScript 9 #1) createrequest with XMLHttpRequest 9 #2) Must supply a Callback function
More informationorg.json - parsing Parsing JSON using org.json
org.json - parsing Parsing JSON using org.json What is parsing? A parser is a component which takes some input and turns it into some datastructure like an object or a tree etc. It allows us to check for
More informationProgramming with the SCA BB Service Configuration API
CHAPTER 3 Programming with the SCA BB Service Configuration API Published: December 23, 2013, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration
More informationProgramming with the SCA BB Service Configuration API
CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: September 17, 2012, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration
More informationProgramming with the SCA BB Service Configuration API
CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: November 8, 2010, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration
More informationFIRE (3473) Dallas Los Angeles Sydney New York London
Traditional project life cycles lasting 12+ months are increasingly putting organizations at a disadvantage to more nimble startups that can innovate and change direction at a faster pace. New Agile development
More informationTrusted Source SSO. Document version 2.3 Last updated: 30/10/2017.
Trusted Source SSO Document version 2.3 Last updated: 30/10/2017 www.iamcloud.com TABLE OF CONTENTS 1 INTRODUCTION... 1 2 PREREQUISITES... 2 2.1 Agent... 2 2.2 SPS Client... Error! Bookmark not defined.
More informationClasses Basic Overview
Final Review!!! Classes and Objects Program Statements (Arithmetic Operations) Program Flow String In-depth java.io (Input/Output) java.util (Utilities) Exceptions Classes Basic Overview A class is a container
More informationToday. Book-keeping. File I/O. Subscribe to sipb-iap-java-students. Inner classes. Debugging tools
Today Book-keeping File I/O Subscribe to sipb-iap-java-students Inner classes http://sipb.mit.edu/iap/java/ Debugging tools Problem set 1 questions? Problem set 2 released tomorrow 1 2 So far... Reading
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationRed Hat Ceph Storage 3
Red Hat Ceph Storage 3 Developer Guide Using the various application programming interfaces for Red Hat Ceph Storage Last Updated: 2018-03-15 Red Hat Ceph Storage 3 Developer Guide Using the various application
More informationCSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2012
Web clients in Java CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2012 The World Wide Web History Main components: URLs, HTTP Protocol, HTML Web support in Java Overview Connecting
More informationThis document is downloaded from DR-NTU, Nanyang Technological University Library, Singapore.
This document is downloaded from DR-NTU, Nanyang Technological University Library, Singapore. Title Web access to cloud system Author(s) Tao, Qingyi Citation Tao, Q. (2014). Web access to cloud system.
More informationBBM 102 Introduction to Programming II Spring Exceptions
BBM 102 Introduction to Programming II Spring 2018 Exceptions 1 Today What is an exception? What is exception handling? Keywords of exception handling try catch finally Throwing exceptions throw Custom
More informationCOMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming
COMP 213 Advanced Object-oriented Programming Lecture 20 Network Programming Network Programming A network consists of several computers connected so that data can be sent from one to another. Network
More informationDomain Name Service. API Reference. Issue 05 Date
Issue 05 Date 2018-08-30 Contents Contents 1 API Invoking Method...1 1.1 Service Usage... 1 1.2 Request Methods... 1 1.3 Request Authentication Methods...2 1.4 Token Authentication...2 1.5 AK/SK Authentication...
More informationEach command-line argument is placed in the args array that is passed to the static main method as below :
1. Command-Line Arguments Any Java technology application can use command-line arguments. These string arguments are placed on the command line to launch the Java interpreter after the class name: public
More informationANN exercise session
ANN exercise session In this exercise session, you will read an external file with Iris flowers and create an internal database in Java as it was done in previous exercise session. A new file contains
More informationA Guide Illustrating the Core Java Equivalent to Selected Tasks Done Using the HSA Class Library
HSA to Core Java A Guide Illustrating the Core Java Equivalent to Selected Tasks Done Using the HSA Class Library The examples below compare how tasks are done using the hsa Console class with how they
More informationNote : That the code coverage tool is not available for Java CAPS Repository based projects.
Code Coverage in Netbeans 6.1 Holger Paffrath August 2009 Code coverage is a simple method used to determine if your unit tests have covered all relevant lines of code in your program. Netbeans has a plugin
More informationRecursion. General Algorithm for Recursion. When to use and not use Recursion. Recursion Removal. Examples
Recursion General Algorithm for Recursion When to use and not use Recursion Recursion Removal Examples Comparison of the Iterative and Recursive Solutions Exercises Unit 19 1 General Algorithm for Recursion
More informationpublic class Q1 { public int x; public static void main(string[] args) { Q1 a = new Q1(17); Q1 b = new Q1(39); public Q1(int x) { this.
CS 201, Fall 2013 Oct 2nd Exam 1 Name: Question 1. [5 points] What output is printed by the following program (which begins on the left and continues on the right)? public class Q1 { public int x; public
More informationThe XML PDF Access API for Java Technology (XPAAJ)
The XML PDF Access API for Java Technology (XPAAJ) Duane Nickull Senior Technology Evangelist Adobe Systems TS-93260 2007 JavaOne SM Conference Session TS-93260 Agenda Using Java technology to manipulate
More informationCS1092: Tutorial Sheet: No 3 Exceptions and Files. Tutor s Guide
CS1092: Tutorial Sheet: No 3 Exceptions and Files Tutor s Guide Preliminary This tutorial sheet requires that you ve read Chapter 15 on Exceptions (CS1081 lectured material), and followed the recent CS1092
More informationGetting Started with the Bullhorn SOAP API and Java
Getting Started with the Bullhorn SOAP API and Java Introduction This article is targeted at developers who want to do custom development using the Bullhorn SOAP API and Java. You will create a sample
More informationStandard Service Controller framework for IBM Cloud marketplace Metered usage from VM/BM s Guide
Standard Service Controller framework for IBM Cloud marketplace Metered usage from VM/BM s Guide Author: Dominique Vernier IBM IT Architect Revision history Version # Date Created by 1.0.170 26 Feb 2015
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationShell Interface Assignment
Page 1 of 9 Shell Interface Assignment Creating a Shell Interface Using Java This assignment consists of modifying a Java program so that it serves as a shell interface that accepts user commands and then
More informationIntroduction to Cisco CDS Software APIs
CHAPTER 1 Cisco Content Delivery System (CDS) software provides HyperText Transport Protocol Secure (HTTPS) application program interfaces (APIs) for monitoring and managing the acquisition and distribution
More informationAlternate Methods for Informatica Metadata Exchange SDK
Alternate Methods for Informatica Metadata Exchange SDK Informatica Metadata Exchange SDK provides a set of COM-based APIs for exchanging metadata with the PowerCenter repository. You can also use this
More informationCS 10: Problem solving via Object Oriented Programming. Web Services
CS 10: Problem solving via Object Oriented Programming Web Services Big picture: query online photo database Flickr and display results Overview Give me pictures of cats Your computer Flickr photo database
More information( &% class MyClass { }
Recall! $! "" # ' ' )' %&! ( &% class MyClass { $ Individual things that differentiate one object from another Determine the appearance, state or qualities of objects Represents any variables needed for
More informationCS506 Web Design & Development Final Term Solved MCQs with Reference
with Reference I am student in MCS (Virtual University of Pakistan). All the MCQs are solved by me. I followed the Moaaz pattern in Writing and Layout this document. Because many students are familiar
More informationSETTING UP YOUR JAVA DEVELOPER ENVIRONMENT
SETTING UP YOUR JAVA DEVELOPER ENVIRONMENT Summary Configure your local dev environment for integrating with Salesforce using Java. This tipsheet describes how to set up your local environment so that
More informationExceptions vs. Errors Exceptions vs. RuntimeExceptions try...catch...finally throw and throws
Lecture 14 Summary Exceptions vs. Errors Exceptions vs. RuntimeExceptions try...catch...finally throw and throws 1 By the end of this lecture, you will be able to differentiate between errors, exceptions,
More informationSETTING UP YOUR JAVA DEVELOPER ENVIRONMENT
SETTING UP YOUR JAVA DEVELOPER ENVIRONMENT Summary Configure your local dev environment for integrating with Salesforce using Java. This tipsheet describes how to set up your local environment so that
More informationDistributed Systems COMP 212. Lecture 8 Othon Michail
Distributed Systems COMP 212 Lecture 8 Othon Michail HTTP Protocol Hypertext Transfer Protocol Used to transmit resources on the WWW HTML files, image files, query results, Identified by Uniform Resource
More informationI/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O
I/O 10-7-2013 I/O in Java I/O streams vs. Reader/Writer HW#3 due today Reading Assignment: Java tutorial on Basic I/O public class Swimmer implements Cloneable { public Date geteventdate() { return (Date)
More informationCustomer: Arinum Solutions. Project: Sircle.
Customer: Solutions Project: Sircle www.arinum.com www.sircle.net Document Owner: Munira Abbas Date: 09 December 2014 Email: munira@arinum.com Version: 2.0 Documents Control Notice to the Recipient of
More informationSimple Image Viewer for IBM Content Navigator
Simple Image Viewer for IBM Content Navigator Type of Submission: Article Title: Simple Image Viewer for IBM Content Navigator Subtitle: Keywords: image, viewer, plug-in, content, navigator, icn Prefix:
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014 Name: This exam consists of 5 problems on the following 6 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet
More informationIntroduction to Cisco CDS Software APIs
CHAPTER 1 Cisco Content Delivery System (CDS) software provides HyperText Transport Protocol Secure (HTTPS) application program interfaces (APIs) for monitoring and managing the acquisition and distribution
More information1.00/ Introduction to Computers and Engineering Problem Solving. Final / December 13, 2004
1.00/1.001 Introduction to Computers and Engineering Problem Solving Final / December 13, 2004 Name: Email Address: TA: Section: You have 180 minutes to complete this exam. For coding questions, you do
More informationArray Basics: Outline. Creating and Accessing Arrays. Creating and Accessing Arrays. Arrays (Savitch, Chapter 7)
Array Basics: Outline Arrays (Savitch, Chapter 7) TOPICS Array Basics Arrays in Classes and Methods Programming with Arrays Searching and Sorting Arrays Multi-Dimensional Arrays Static Variables and Constants
More informationProgramming Assignment Comma Separated Values Reader Page 1
Programming Assignment Comma Separated Values Reader Page 1 Assignment What to Submit 1. Write a CSVReader that can read a file or URL that contains data in CSV format. CSVReader provides an Iterator for
More informationJava reflection. alberto ferrari university of parma
Java reflection alberto ferrari university of parma reflection metaprogramming is a programming technique in which computer programs have the ability to treat programs as their data a program can be designed
More informationIntroduction to Software Development (ISD) Week 3
Introduction to Software Development (ISD) Week 3 Autumn term 2012 Aims of Week 3 To learn about while, for, and do loops To understand and use nested loops To implement programs that read and process
More informationProject #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.
Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple magazine data system. Milestones:
More informationCloud Trace Service. API Reference. Issue 01 Date
Issue 01 Date 2016-12-30 Contents Contents 1 API Calling... 1 1.1 Service Usage... 1 1.2 Making a Request... 1 1.3 Request Authentication Methods...2 1.4 Token Authentication...2 1.5 AK/SK Authentication...
More informationIntroduction This assignment will ask that you write a simple graphical user interface (GUI).
Computing and Information Systems/Creative Computing University of London International Programmes 2910220: Graphical Object-Oriented and Internet programming in Java Coursework one 2011-12 Introduction
More informationAim behind client server architecture Characteristics of client and server Types of architectures
QA Automation - API Automation - All in one course Course Summary: In detailed, easy, step by step, real time, practical and well organized Course Not required to have any prior programming knowledge,
More informationCopyright 2014 Blue Net Corporation. All rights reserved
a) Abstract: REST is a framework built on the principle of today's World Wide Web. Yes it uses the principles of WWW in way it is a challenge to lay down a new architecture that is already widely deployed
More informationAn article on collecting IBM InfoSphere CDC Subscription health matrices in a Java program using the Monitoring API
An article on collecting IBM InfoSphere CDC Subscription health matrices in a Java program using the Monitoring API Aniket Kadam(anikadam@in.ibm.com) Prerequisites Before going through the article reader
More informationInformatica PIM. Data Lookup via Java Transformations. Version: Date:
Informatica PIM Data Lookup via Java Transformations Version: Date: 23 July 29, 2014 Table of Contents Introduction 3 Step-by-step example 3 Create a new Java Transformation 3 Include code to retrieve
More information,pm-diffs.patch -408, ,13
,pm-diffs.patch diff -r 763e4be166aa edu.harvard.i2b2.pm/src/edu/harvard/i2b2/pm/delegate/serviceshandler.java --- a/edu.harvard.i2b2.pm/src/edu/harvard/i2b2/pm/delegate/serviceshandler.java Wed Aug 11
More informationAppendix C WORKSHOP. SYS-ED/ Computer Education Techniques, Inc.
Appendix C WORKSHOP SYS-ED/ Computer Education Techniques, Inc. 1 Preliminary Assessment Specify key components of WSAD. Questions 1. tools are used for reorganizing Java classes. 2. tools are used to
More informationAPI Developer Notes. A Galileo Web Services Java Connection Class Using Axis. 29 June Version 1.3
API Developer Notes A Galileo Web Services Java Connection Class Using Axis 29 June 2012 Version 1.3 THE INFORMATION CONTAINED IN THIS DOCUMENT IS CONFIDENTIAL AND PROPRIETARY TO TRAVELPORT Copyright Copyright
More informationProject 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently.
Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple movie data system. Milestones: 1. Use
More informationOverview of Web Services API
CHAPTER 1 The Cisco IP Interoperability and Collaboration System (IPICS) 4.0(x) application programming interface (API) provides a web services-based API that enables the management and control of various
More informationCustomizing the WebSphere Portal login and logout commands
Customizing the WebSphere Portal login and logout commands Abstract This technical note provides detailed information about how the WebSphere Portal login or logout flow can be extended or customized by
More informationJava in 21 minutes. Hello world. hello world. exceptions. basic data types. constructors. classes & objects I/O. program structure.
Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static
More informationIT101. File Input and Output
IT101 File Input and Output IO Streams A stream is a communication channel that a program has with the outside world. It is used to transfer data items in succession. An Input/Output (I/O) Stream represents
More informationFull file at
Chapter 1 Primitive Java Weiss 4 th Edition Solutions to Exercises (US Version) 1.1 Key Concepts and How To Teach Them This chapter introduces primitive features of Java found in all languages such as
More informationProject #1 Computer Science 2334 Fall 2008
Project #1 Computer Science 2334 Fall 2008 User Request: Create a Word Verification System. Milestones: 1. Use program arguments to specify a file name. 10 points 2. Use simple File I/O to read a file.
More informationJava Intro 3. Java Intro 3. Class Libraries and the Java API. Outline
Java Intro 3 9/7/2007 1 Java Intro 3 Outline Java API Packages Access Rules, Class Visibility Strings as Objects Wrapper classes Static Attributes & Methods Hello World details 9/7/2007 2 Class Libraries
More informationObject oriented programming. Instructor: Masoud Asghari Web page: Ch: 3
Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning
More informationBBM 102 Introduction to Programming II Spring 2017
BBM 102 Introduction to Programming II Spring 2017 Exceptions Instructors: Ayça Tarhan, Fuat Akal, Gönenç Ercan, Vahid Garousi Today What is an exception? What is exception handling? Keywords of exception
More information16-Dec-10. Consider the following method:
Boaz Kantor Introduction to Computer Science IDC Herzliya Exception is a class. Java comes with many, we can write our own. The Exception objects, along with some Java-specific structures, allow us to
More informationintroduction to using Watson Services with Java on Bluemix
introduction to using Watson Services with Java on Bluemix Patrick Mueller @pmuellr, muellerware.org developer advocate for IBM's Bluemix PaaS http://pmuellr.github.io/slides/2015/02-java-intro-with-watson
More informationWriting REST APIs with OpenAPI and Swagger Ada
Writing REST APIs with OpenAPI and Swagger Ada Stéphane Carrez FOSDEM 2018 OpenAPI and Swagger Ada Introduction to OpenAPI and Swagger Writing a REST Ada client Writing a REST Ada server Handling security
More informationBackend. (Very) Simple server examples
Backend (Very) Simple server examples Web server example Browser HTML form HTTP/GET Webserver / Servlet JDBC DB Student example sqlite>.schema CREATE TABLE students(id integer primary key asc,name varchar(30));
More informationIntroduction to Cisco ECDS Software APIs
CHAPTER 1 This chapter contains the following sections: Overview of HTTPS APIs, page 1-1 Calling the HTTPS APIs, page 1-2 Sample Java Program, page 1-3 API Error Messages, page 1-5 API Tasks, page 1-7
More informationJava: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation.
Java: Classes Introduction A class defines the abstract characteristics of a thing (object), including its attributes and what it can do. Every Java program is composed of at least one class. From a programming
More information09-1. CSE 143 Java GREAT IDEAS IN COMPUTER SCIENCE. Overview. Data Representation. Representation of Primitive Java Types. Input and Output.
CSE 143 Java Streams Reading: 19.1, Appendix A.2 GREAT IDEAS IN COMPUTER SCIENCE REPRESENTATION VS. RENDERING 4/28/2002 (c) University of Washington 09-1 4/28/2002 (c) University of Washington 09-2 Topics
More informationDesign Patterns: Part 2
Design Patterns: Part 2 ENGI 5895: Software Design Andrew Vardy with code samples from Dr. Rodrigue Byrne and [Martin(2003)] Faculty of Engineering & Applied Science Memorial University of Newfoundland
More information2018/2/5 话费券企业客户接入文档 语雀
1 2 2 1 2 1 1 138999999999 2 1 2 https:lark.alipay.com/kaidi.hwf/hsz6gg/ppesyh#2.4-%e4%bc%81%e4%b8%9a%e5%ae%a2%e6%88%b7%e6%8e%a5%e6%94%b6%e5%85%85%e5 1/8 2 1 3 static IAcsClient client = null; public static
More informationWOSO Source Code (Java)
WOSO 2017 - Source Code (Java) Q 1 - Which of the following is false about String? A. String is immutable. B. String can be created using new operator. C. String is a primary data type. D. None of the
More informationContents Introduction... 5 Using Gateway API... 9 Using SampleRestAPI Security Troubleshooting Gateway API Legal Notices...
Gateway API Programming Guide Version 17 July 2017 Contents Introduction... 5 Prerequisites for On-Premises... 5 REST Style Architecture... 5 Using Gateway API... 9 Sample Java Code that Invokes the API
More informationTools : The Java Compiler. The Java Interpreter. The Java Debugger
Tools : The Java Compiler javac [ options ] filename.java... -depend: Causes recompilation of class files on which the source files given as command line arguments recursively depend. -O: Optimizes code,
More informationBinghamton University. CS-140 Fall Problem Solving. Creating a class from scratch
Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods
More informationDeveloping Clients for a JAX-WS Web Service
Developing Clients for a JAX-WS Web Service {scrollbar} This tutorial will take you through the steps required in developing, deploying and testing a Web Service Client in Apache Geronimo for a web services
More informationCSPP : Introduction to Object-Oriented Programming
CSPP 511-01: Introduction to Object-Oriented Programming Harri Hakula Ryerson 256, tel. 773-702-8584 hhakula@cs.uchicago.edu August 7, 2000 CSPP 511-01: Lecture 15, August 7, 2000 1 Exceptions Files: Text
More informationObject Oriented Programming and Design in Java. Session 2 Instructor: Bert Huang
Object Oriented Programming and Design in Java Session 2 Instructor: Bert Huang Announcements TA: Yipeng Huang, yh2315, Mon 4-6 OH on MICE clarification Next Monday's class canceled for Distinguished Lecture:
More informationCS 2113 Software Engineering
CS 2113 Software Engineering Java 6: File and Network IO https://github.com/cs2113f18/template-j-6-io.git Professor Tim Wood - The George Washington University Project 2 Zombies Basic GUI interactions
More informationCOT 3530: Data Structures. Giri Narasimhan. ECS 389; Phone: x3748
COT 3530: Data Structures Giri Narasimhan ECS 389; Phone: x3748 giri@cs.fiu.edu www.cs.fiu.edu/~giri/teach/3530spring04.html Evaluation Midterm & Final Exams Programming Assignments Class Participation
More informationRest Client for MicroProfile. John D. Ament
Rest Client for MicroProfile John D. Ament 1.0-T9, December 05, 2017 Table of Contents Microprofile Rest Client..................................................................... 2 MicroProfile Rest
More informationApache Wink User Guide
Apache Wink User Guide Software Version: 0.1 The Apache Wink User Guide document is a broad scope document that provides detailed information about the Apache Wink 0.1 design and implementation. Apache
More informationJava Input/Output. 11 April 2013 OSU CSE 1
Java Input/Output 11 April 2013 OSU CSE 1 Overview The Java I/O (Input/Output) package java.io contains a group of interfaces and classes similar to the OSU CSE components SimpleReader and SimpleWriter
More informationJOURNAL OF OBJECT TECHNOLOGY
JOURNAL OF OBJECT TECHNOLOGY Online at http://www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2010 Vol. 9, No. 1, January-February 2010 A Modern, Compact Implementation of the Parameterized
More informationExceptions and Libraries
Exceptions and Libraries RS 9.3, 6.4 Some slides created by Marty Stepp http://www.cs.washington.edu/143/ Edited by Sarah Heckman 1 Exceptions exception: An object representing an error or unusual condition.
More informationPractice exam for CMSC131-04, Fall 2017
Practice exam for CMSC131-04, Fall 2017 Q1 makepalindrome - Relevant topics: arrays, loops Write a method makepalidrome that takes an int array, return a new int array that contains the values from the
More informationJava Bytecode (binary file)
Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.
More informationXML Test Drivers. CLI to SOAP/CORBA XML Transaction APPENDIXB. This appendix details the XML test drivers.
APPENDIXB Revised: July 2010, This appendix details the XML test drivers. CLI to SOAP/CORBA XML Transaction The following sample test driver executes a normal CLI command, but processes it as a SOAP or
More informationSSC - Web applications and development Introduction and Java Servlet (I)
SSC - Web applications and development Introduction and Java Servlet (I) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics What will we learn
More information