简体   繁体   中英

Why am I getting a NoSuchFileException when running readAllBytes on this file

I am trying to make a simple android app that uses OpenAPLR

http://doc.openalpr.com/cloud_api.html

So I copied the code under the Java section on how to make a REST api request and put it all into onClick method of a button and took a picture of a license plate and saved it as license_plate.jpg in the location

app/res/drawable/license_plate.jpg

But whenever I run the application I always get an error pointing to these lines

Path path = Paths.get("drawable/license_plate.jpg");
byte[] data = Files.readAllBytes(path);

java.nio.file.NoSuchFileException: drawable/license_plate.jpg

Where should I be saving this image so I can use it during the application? And where should I be saving images used for future applications when I am not just using a single picture I have already preloaded?

You give wrong path. You can only save a picture in your device and then give image folder path for example :

Path path = Paths.get("/storage/projects/alpr/samples/testing/car1.jpg");
byte[] data = Files.readAllBytes(path);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM