not able to read fiile GmailQuickstart.class.getResourceAsStream("E:\\client_secret.json");

619 views Asked by At

I am using the source code that I got from https://developers.google.com/gmail/api/quickstart/java When I am running this in eclipse I am getting error

Exception in thread "main" java.lang.NullPointerException
    at java.io.Reader.<init>(Unknown Source)
    at java.io.InputStreamReader.<init>(Unknown Source)
    at googleemailid.GmailQuickstart.authorize(GmailQuickstart.java:79)
    at googleemailid.GmailQuickstart.getGmailService(GmailQuickstart.java:101)
    at googleemailid.GmailQuickstart.main(GmailQuickstart.java:109)

InputStream in =GmailQuickstart.class.getResourceAsStream("E:\\client_secret.json");

    GoogleClientSecrets clientSecrets =
        GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));

Error comes at GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));

For debugging I tried to read the file using the InputStream and its able to read the file and file is present with full permission. Also I got following warning.

Jun 08, 2015 5:45:43 AM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: C:\Users\Abc\.credentials\gmail-api-quickstart
Jun 08, 2015 5:45:43 AM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\Abc\.credentials\gmail-api-quickstart
0

There are 0 answers