0

spring mvc の Web アプリケーションでスキャナーを実行すると、このエラーが発生します。メソッド byte を使用し、それをバイト配列として返します。ここがエラーだと思います

uk.co.mmscomputing.device.twain.TwainIOException: uk.co.mmscomputing.device.twain.TwainScanner.setException:
    uk.co.mmscomputing.device.twain.TwainSource.checkState:
    Source not in state 3 but in state 5.
    at uk.co.mmscomputing.device.twain.TwainScanner.signalException(TwainScanner.java:131)
    at uk.co.mmscomputing.device.twain.jtwain.signalException(jtwain.java:287)
    at uk.co.mmscomputing.device.twain.jtwain.cbexecute(jtwain.java:243)
    at uk.co.mmscomputing.device.twain.jtwain.nstart(Native Method)
    at uk.co.mmscomputing.device.twain.jtwain.access$200(jtwain.java:12)
    at uk.co.mmscomputing.device.twain.jtwain$1.run(jtwain.java:338)
uk.co.mmscomputing.device.twain.TwainIOException: uk.co.mmscomputing.device.twain.TwainSource.checkState:
    Source not in state 3 but in state 5.
    at uk.co.mmscomputing.device.twain.TwainSource.checkState(TwainSource.java:48)
    at uk.co.mmscomputing.device.twain.TwainSourceManager.openSource(TwainSourceManager.java:90)
    at uk.co.mmscomputing.device.twain.jtwain.cbexecute(jtwain.java:234)
    at uk.co.mmscomputing.device.twain.jtwain.nstart(Native Method)
    at uk.co.mmscomputing.device.twain.jtwain.access$200(jtwain.java:12)
    at uk.co.mmscomputing.device.twain.jtwain$1.run(jtwain.java:338)

私のコードは次のとおりです。

@RequestMapping( value = "/scanImage", method = RequestMethod.GET )
@ResponseBody
public byte[] scanImage()
{

    ByteArrayOutputStream byteArrayOutputStream = null;
    Scanner scanner = null;

    try
    {

        SCANIMAGE scanImage = new SCANIMAGE();
        scanImage.scanStarter();
        byte[] buffer = new byte[4096];
        byteArrayOutputStream = new ByteArrayOutputStream();
        FileInputStream inputStream = new FileInputStream( "D:/IMAGE.jpg" );
        System.out.println( "IMAGE Number : D:/IMAGE.jpg" );

        int read = 0;


        while ( ( read = inputStream.read( buffer ) ) != -1 )
        {
            byteArrayOutputStream.write( buffer, 0, read );

        }
    }
    catch ( ScannerIOException e )
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    catch ( FileNotFoundException e )
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    catch ( IOException e )
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return byteArrayOutputStream.toByteArray();
}
4

0 に答える 0