Skip to content

Commit a516337

Browse files
committed
adding code tags
1 parent 0d20f1e commit a516337

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

java/InkRecognition/quickstart/RecognizeInk.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
3-
3+
// <imports>
44
import org.apache.http.HttpEntity;
55
import org.apache.http.client.methods.CloseableHttpResponse;
66
import org.apache.http.client.methods.HttpPost;
@@ -11,29 +11,33 @@
1111
import java.io.IOException;
1212
import java.nio.file.Files;
1313
import java.nio.file.Paths;
14+
// </imports>
1415

1516
public 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

Comments
 (0)