11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT License.
3-
3+ // <imports>
44import org .apache .http .HttpEntity ;
55import org .apache .http .client .methods .CloseableHttpResponse ;
66import org .apache .http .client .methods .HttpPost ;
1111import java .io .IOException ;
1212import java .nio .file .Files ;
1313import java .nio .file .Paths ;
14+ // </imports>
1415
1516public class RecognizeInk {
16-
17+ // <vars>
1718 // Replace the subscriptionKey string value with your valid subscription key.
1819 private static final String subscriptionKey = "YOUR_SUBSCRIPTION_KEY" ;
1920 // Replace the dataPath string with a path to the JSON formatted ink stroke data file.
2021 public static final String rootUrl = "https://api.cognitive.microsoft.com" ;
2122 public static final String inkRecognitionUrl = "/inkrecognizer/v1.0-preview/recognize" ;
22- private static final String dataPath = "PATH_TO_INK_STROKE_DATA" ;
23-
23+ private static final String dataPath = "C:\\ Users\\ aahil\\ Code\\ work\\ cognitive-services-REST-api-samples\\ java\\ InkRecognition\\ quickstart\\ example-response.json" ;
24+ // </vars>
25+ // <main>
2426 public static void main (String [] args ) throws Exception {
2527
2628 String requestData = new String (Files .readAllBytes (Paths .get (dataPath )), "utf-8" );
2729 recognizeInk (requestData );
2830 }
29-
31+ // </main>
32+ // <recognizeInk>
3033 static void recognizeInk (String requestData ) {
3134 System .out .println ("Sending an Ink recognition request." );
3235
3336 String result = sendRequest (rootUrl , inkRecognitionUrl , subscriptionKey , requestData );
3437 System .out .println (result );
3538 }
36-
39+ // </recognizeInk>
40+ // <sendRequest>
3741 static String sendRequest (String endpoint , String apiAddress , String subscriptionKey , String requestData ) {
3842 try (CloseableHttpClient client = HttpClients .createDefault ()) {
3943 HttpPost request = new HttpPost (endpoint + apiAddress );
@@ -55,4 +59,5 @@ static String sendRequest(String endpoint, String apiAddress, String subscriptio
5559 }
5660 return null ;
5761 }
62+ // </sendRequest>
5863}
0 commit comments