2

I am loading a client secret file client_secrets.json

  InputStream s = MyClass.class.getResourceAsStream("WEB-INF/client_secrets.json");
  InputStreamReader r = new InputStreamReader(s);
  GoogleClientSecrets clientSecrets =
          GoogleClientSecrets.load(jsonFactory,r);

I keep getting null pointers error at line 2, I am now led to believe that the file couldn't be located. My directory tree looks something like this:

/src
  MyClass.java
/war
  /WEB-INF
    client_secrets.json

Should I use relative path to my java file?

Bonk
  • 1,669
  • 7
  • 26
  • 44

1 Answers1

0

I think the answer can be found here

InputStream s = MyClass.getClass().getClassLoader().getResourceAsStream("WEB-INF/client_secrets.json")
Community
  • 1
  • 1
IlGala
  • 3,043
  • 3
  • 31
  • 46