getResourceAsStream returning null despite called file being in same dir as class getResourceAsStream is called in

前端 未结 2 2021
轻奢々
轻奢々 2020-12-20 03:21

I imported an Android sample coded by Amazon involving AWS\'s DynamoDB which I got from here and was presumably written for Eclipse: https://github.com/awslabs/aws-sdk-andro

2条回答
  •  青春惊慌失措
    2020-12-20 04:06

    Created a dir called resources under /src/main/ and placed AwsCredentials.properties there and used

    properties.load( PropertyLoader.class.getClassLoader().getResourceAsStream( "AwsCredentials.properties" ) );
    

    instead of

    properties.load( this.getClass().getResourceAsStream("AwsCredentials.properties" ) );
    

    Not as elegant as I would like, but it works.

提交回复
热议问题