title: How to fix "Error: Invalid GCS Path Specified" when using Java with Google's Vision API?
body: <p>I am currently following this example on the Vision API docs:<a href="https://cloud.google.com/vision/docs/ocr?apix_params=%7B%22resource%22%3A%7B%22requests%22%3A%5B%7B%22features%22%3A%5B%7B%22type%22%3A%22TEXT_DETECTION%22%7D%5D%2C%22image%22%3A%7B%22source%22%3A%7B%22imageUri%22%3A%22https%3A%2F%2Fwww.w3.org%2FTR%2FSVGTiny12%2Fexamples%2FtextArea01.png%22%7D%7D%7D%5D%7D%7D#vision_text_detection_gcs-java" rel="nofollow noreferrer">found here</a></p>
  
  <pre><code>
  import com.google.cloud.vision.v1.*;
  import com.google.cloud.vision.v1.Feature.Type;
  import java.io.File;
  import java.io.IOException;
  import java.io.PrintStream;
  import java.util.ArrayList;
  import java.util.List;
  
  public class VisionApiTest {
      public static void main(String... args) throws Exception {
  
          PrintStream stream = new PrintStream(new File("src/test.txt"));
  
          detectTextGcs("https://www.w3.org/TR/SVGTiny12/examples/textArea01.png", stream);
      }
  
      public static void detectTextGcs(String gcsPath, PrintStream out) throws Exception, IOException {
          List&lt;AnnotateImageRequest&gt; requests = new ArrayList&lt;&gt;();
  
          ImageSource imgSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build();
          Image img = Image.newBuilder().setSource(imgSource).build();
          Feature feat = Feature.newBuilder().setType(Type.TEXT_DETECTION).build();
          AnnotateImageRequest request =
                  AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
          requests.add(request);
  
          try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
              BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
              List&lt;AnnotateImageResponse&gt; responses = response.getResponsesList();
  
              for (AnnotateImageResponse res : responses) {
                  if (res.hasError()) {
                      out.printf("Error: %s\n", res.getError().getMessage());
                      return;
                  }
  
                  // For full list of available annotations, see http://g.co/cloud/vision/docs
                  for (EntityAnnotation annotation : res.getTextAnnotationsList()) {
                      out.printf("Text: %s\n", annotation.getDescription());
                      out.printf("Position : %s\n", annotation.getBoundingPoly());
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>After passing in the gcsPath String into the detectTextGcs method in the example, I am given the error: "Error: Invalid GCS path specified: <a href="https://www.w3.org/TR/SVGTiny12/examples/textArea01.png" rel="nofollow noreferrer">https://www.w3.org/TR/SVGTiny12/examples/textArea01.png</a>"</p>
  
  <p>I am expecting for the PrintStream object to write to the file the text that is held within the picture which will be "Tomorrow, and\ntomorrow, and\ntomorrow; blah blah blah...". After trying the API on Vision API doc page mentioned above, it works fine, but not within IntelliJ. </p>
  
  <p>Any help is greatly appreciated. Thank you. (Also forgive me if this isn't a well worded question, it's my first time posting)</p>