I am trying to download atext file by usig Google Cloud Storage Java API as follow:
The file is located at "gs://bucket_name/dir/file.json
I am using below codes
bucket_name="name_of_bucket",
Storage storage = StorageOptions.getDefaultInstance().getService();
Blob blob = storage.get(BlobId.of(bucket_name, "dir/file.jason"));
//ReadChannel r = blob.reader();
return blob.toString();
However, whenever I using my code I get below exception:
Exception in thread "main" java.lang.NullPointerException
at com.mahdi.handlers.GCSHandler.readJsonFile(GCSHandler.java:30)
at com.mahdi.handlers.GCSHandler.main(GCSHandler.java:37)
I am not sure if I am giving right parameter for Bucket_Name and OBJECT_NAME in below line:
Blob blob = storage.get(BlobId.of(bucketName, "dir/file.json"));