Code review comment: oh no. how sad :( is this global for all Java?

Code before review:
public static void main(String[] args) throws IOException {
FormRecognizerAsyncClient client = new FormRecognizerClientBuilder()
.credential(new AzureKeyCredential("{key}"))
.endpoint("https:
.buildAsyncClient();
File sourceFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/resources/"
+ "sample-forms/forms/selectionMarkForm.pdf");
byte[] fileContent = Files.readAllBytes(sourceFile.toPath());
String modelId = "{modelId}";
PollerFlux<FormRecognizerOperationResult, List<RecognizedForm>> recognizeFormPoller;
try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {
recognizeFormPoller = client.beginRecognizeCustomForms(modelId, toFluxByteBuffer(targetStream),
sourceFile.length(), new RecognizeCustomFormsOptions().setFieldElementsIncluded(true));
}
Mono<List<RecognizedForm>> recognizeFormResult =
recognizeFormPoller
.last()
.flatMap(pollResponse -> {
if (pollResponse.getStatus().isComplete()) {
return pollResponse.getFinalResult();
} else {
return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:"
+ pollResponse.getStatus()));
}
});
recognizeFormResult.subscribe(recognizedForms -> {
for (int i = 0; i < recognizedForms.size(); i++) {
final RecognizedForm form = recognizedForms.get(i);
System.out.printf("----------- Recognized custom form info for page %d -----------%n", i);
System.out.printf("Form type: %s%n", form.getFormType());
System.out.printf("Form has form type confidence : %.2f%n", form.getFormTypeConfidence());
System.out.printf("Form was analyzed with model with ID: %s%n", form.getModelId());
form.getFields().forEach((label, formField) -> {
System.out.printf("Field '%s' has label '%s' with confidence score of %.2f.%n", label,
formField.getLabelData().getText(),
formField.getConfidence());
});
final List<FormPage> pages = form.getPages();
for (int i1 = 0; i1 < pages.size(); i1++) {
final FormPage formPage = pages.get(i1);
System.out.printf("------- Recognizing info on page %s of Form ------- %n", i1);
System.out.printf("Has width: %f, angle: %.2f, height: %f %n", formPage.getWidth(),
formPage.getTextAngle(), formPage.getHeight());
System.out.println("Recognized Tables: ");
final List<FormTable> tables = formPage.getTables();
for (int i2 = 0; i2 < tables.size(); i2++) {
final FormTable formTable = tables.get(i2);
System.out.printf("Table %d%n", i2);
formTable.getCells()
.forEach(formTableCell -> {
System.out.printf("Cell text %s has following words: %n", formTableCell.getText());
formTableCell.getFieldElements().stream()
.filter(formContent -> formContent instanceof FormSelectionMark)
.map(formContent -> (FormSelectionMark) (formContent))
.forEach(selectionMark ->
System.out.printf("Page: %s, Selection mark is %s within bounding box %s has a "
+ "confidence score %.2f.%n",
selectionMark.getPageNumber(),
selectionMark.getState(),
selectionMark.getBoundingBox().toString(),
selectionMark.getConfidence()));
});
System.out.println();
}
}
}
});
try {
TimeUnit.MINUTES.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

Line under review: File sourceFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/resources/"

Code after addressing the review:
public static void main(String[] args) throws IOException {
FormRecognizerAsyncClient client = new FormRecognizerClientBuilder()
.credential(new AzureKeyCredential("{key}"))
.endpoint("https:
.buildAsyncClient();
File sourceFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/resources/"
+ "sample-forms/forms/selectionMarkForm.pdf");
byte[] fileContent = Files.readAllBytes(sourceFile.toPath());
String modelId = "{modelId}";
PollerFlux<FormRecognizerOperationResult, List<RecognizedForm>> recognizeFormPoller;
try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {
recognizeFormPoller = client.beginRecognizeCustomForms(modelId, toFluxByteBuffer(targetStream),
sourceFile.length(), new RecognizeCustomFormsOptions().setFieldElementsIncluded(true));
}
Mono<List<RecognizedForm>> recognizeFormResult =
recognizeFormPoller
.last()
.flatMap(pollResponse -> {
if (pollResponse.getStatus().isComplete()) {
return pollResponse.getFinalResult();
} else {
return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:"
+ pollResponse.getStatus()));
}
});
recognizeFormResult.subscribe(recognizedForms -> {
for (int i = 0; i < recognizedForms.size(); i++) {
final RecognizedForm form = recognizedForms.get(i);
System.out.printf("----------- Recognized custom form info for page %d -----------%n", i);
System.out.printf("Form type: %s%n", form.getFormType());
System.out.printf("Form has form type confidence : %.2f%n", form.getFormTypeConfidence());
System.out.printf("Form was analyzed with model with ID: %s%n", form.getModelId());
form.getFields().forEach((label, formField) -> {
System.out.printf("Field '%s' has label '%s' with confidence score of %.2f.%n", label,
formField.getLabelData().getText(),
formField.getConfidence());
});
final List<FormPage> pages = form.getPages();
for (int i1 = 0; i1 < pages.size(); i1++) {
final FormPage formPage = pages.get(i1);
System.out.printf("------- Recognizing info on page %s of Form ------- %n", i1);
System.out.printf("Has width: %f, angle: %.2f, height: %f %n", formPage.getWidth(),
formPage.getTextAngle(), formPage.getHeight());
System.out.println("Recognized Tables: ");
final List<FormTable> tables = formPage.getTables();
for (int i2 = 0; i2 < tables.size(); i2++) {
final FormTable formTable = tables.get(i2);
System.out.printf("Table %d%n", i2);
formTable.getCells()
.forEach(formTableCell -> {
System.out.printf("Cell text %s has following words: %n", formTableCell.getText());
formTableCell.getFieldElements().stream()
.filter(formContent -> formContent instanceof FormSelectionMark)
.map(formContent -> (FormSelectionMark) (formContent))
.forEach(selectionMark ->
System.out.printf("Page: %s, Selection mark is %s within bounding box %s has a "
+ "confidence score %.2f.%n",
selectionMark.getPageNumber(),
selectionMark.getState(),
selectionMark.getBoundingBox().toString(),
selectionMark.getConfidence()));
});
System.out.println();
}
}
}
});
try {
TimeUnit.MINUTES.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}