public static void main()

in document_ai_warehouse/document-ai-warehouse-java-samples/src/main/java/org/example/CreateDocument.java [130:169]


  public static void main(final String[] args) {
    String projectNumber = System.getenv("PROJECT_NUMBER");
    if (projectNumber == null) {
      System.err.println("No PROJECT_NUMBER environment variable set");
      return;
    }
    String userid = System.getenv("USERID");
    if (userid == null) {
      System.err.println("No USERID environment variable set");
      return;
    }
    String location = System.getenv("LOCATION");
    if (location == null) {
      location = "us"; // Default to us location
    }

    if (args.length < 2) {
      System.err.println("Usage: CreateDocument [SCHEMA_NAME] [FILENAME]");
      return;
    }

    String schemaName = args[0]; // Name of schema to associate with document.
    String fileName = args[1]; // Local file name of document.

    try {
      // Read the document data into memory for passing to
      // Document AI Warehouse.
      ByteString fileData = ByteString.readFrom(new FileInputStream(fileName));
      CreateDocument app = new CreateDocument();
      app.setProjectNumber(projectNumber);
      app.setUserId(userid);
      app.setLocation(location);
      app.createDocument(schemaName, fileData);
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }

    System.out.println("CreateDocument completed");
  } // main