I am trying to run scanimage command from java. Command is successfully executed but i can't read image that is returned from command. I want to read image from terminal and convert it to base64 string via Java. My code:
public String getimagefromscanner(String device)
{
    try {
        Process p = Runtime.getRuntime().exec("scanimage --resolution=300 -l 0 -t 0 -y 297 -x 210 --device-name " + device);
        BufferedInputStream input = new BufferedInputStream(p.getInputStream());
        byte[] file = new byte[input.available()];
        input.read(file);
        String result = new String(Base64.getDecoder().decode(file));
        p.waitFor();
        p.destroy();
        return result;
    } catch (IOException e) {
        return  e.getLocalizedMessage();
    } catch (InterruptedException e) {
        return  e.getLocalizedMessage();
    }
}
