Not able to read a file from my assets folder

+1 vote

I am trying to read a file in my assets folder. The library is: Web3j's wallet utility class. I am not able to find the json file though. The json file is located in the assets folder but i can not find it.

currentWallet = WalletUtils.loadCredentials(password , "/some.json");

The stacktrace is as follows:

W/Java7Support: Unable to load JDK7 types (annotations, java.nio.file.Path): no Java7 support added
E/Main Activity: onCreate: 
        keystore.json (No such file or directory)
                     at Method)
                     at com.fasterxml.jackson.core.JsonFactory.createParser(
                     at com.fasterxml.jackson.databind.ObjectMapper.readValue(
                     at org.web3j.crypto.WalletUtils.loadCredentials(
                     at org.web3j.crypto.WalletUtils.loadCredentials(
                     at java.lang.reflect.Method.invoke(Native Method)
                     at android.view.View.performClick(
                     at android.widget.TextView.performClick(
                     at android.view.View$
                     at android.os.Handler.handleCallback(
                     at android.os.Handler.dispatchMessage(
                     at android.os.Looper.loop(
                     at java.lang.reflect.Method.invoke(Native Method)

Please help

Oct 22, 2018 in Blockchain by digger
• 27,620 points

3 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can try this:

private BufferedReader file = new BufferedReader(new InputStreamReader(getAssets().open("file.json")));
answered Oct 22, 2018 by Omkar
• 65,850 points
0 votes

I found another way on the internet to solve this issue:

public String ReadDataFromFile(String file) {
    String data = "";

try {
    InputStream stream = getAssets().open(file);

    int size = stream.available();
    byte[] buffer = new byte[size];;
    data = new String(buffer);
} catch (IOException e) {
    // Handle exceptions here

return data;

and Use like

 String yourData = ReadDataFromFile("YourDataFile.json");
answered Oct 25, 2018 by Omkar
• 65,850 points
0 votes

Hi.. I faced a similar problem in my project, following is the solution that worked for me:

public static String getJSONFileFromAsset(String filename, Context context) throws IOException {
    AssetManager manager = context.getAssets();
    InputStream file =;
    byte[] formArray = new byte[file.available()];;
    return new String(formArray);
answered Oct 25, 2018 by Shrikanth

Related Questions In Blockchain

0 votes
1 answer

Not Able to register a user with Hyperledger-Fabric v1.1 preview

The error: "Certificate not found with AKI 'e729224e8b3f31784c8a93c5b8ef6f4c1c91d9e6e577c45c33163609fe40011' ...READ MORE

answered Jun 16, 2018 in Blockchain by charlie_brown
• 7,710 points
0 votes
1 answer

Not able to execute a deployed contract?

The problem is that you are not ...READ MORE

answered Jul 29, 2018 in Blockchain by digger
• 27,620 points
0 votes
1 answer

Not able to run Bitcoin’s file.

Installing autoconf and automake would solve the ...READ MORE

answered Aug 22, 2018 in Blockchain by slayer
• 29,040 points
0 votes
1 answer

How to read file from in python?

you call: out, err = p.communicate() READ MORE

answered Aug 24, 2018 in Blockchain by digger
• 27,620 points
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
0 votes
1 answer
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,320 points
0 votes
1 answer

Hyperledger composer: Not able to issue identities from a Business network.

To specify your own affiliation you need ...READ MORE

answered Nov 6, 2018 in Blockchain by Omkar
• 65,850 points
0 votes
1 answer

Not able to invoke a contract in Ethereum Private chain using geth

Hope this helps: contract mortal { /* ...READ MORE

answered Oct 22, 2018 in Blockchain by Omkar
• 65,850 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.