-1

Androidで使用したいJavaで開発されたコードからエラーが発生しています。

ImageIO.write(input, file, cos)

これらは Android の次のコードに対する私のエラーです。コードは Java で動作します。

 public void decryptFile(String key, String typeFile) throws InvalidKeyException, 
                                                          NoSuchAlgorithmException, 
                                                       InvalidKeySpecException, 
                                                            NoSuchPaddingException, 
                                                                       IOException
   {

       DESKeySpec dks = new DESKeySpec(key.getBytes());
       SecretKeyFactory skf = SecretKeyFactory.getInstance("DES");
       SecretKey desKey = skf.generateSecret(dks);
       Cipher pbeCipher = Cipher.getInstance("DES"); // DES/ECB/PKCS5Padding for SunJCE

       pbeCipher.init(Cipher.DECRYPT_MODE, desKey);    


        // Decrypt the ciphertext and then print it out.     
        FileInputStream output = null;

        File encryptedFile = new File(Environment.getExternalStorageDirectory() + "/images/Et1.jpg");   
        File decryptedFile = new File(Environment.getExternalStorageDirectory() + "/images/Dt1.jpg");


        try 
        {

        output = new FileInputStream(encryptedFile);
        } 
        catch (FileNotFoundException e) 
        {
        // TODO Auto-generated catch block
        e.printStackTrace();
        }

    CipherInputStream cis = new CipherInputStream(output, pbeCipher);
    BufferedImage input = null;

    try 
    {
        input = ImageIO.read(cis);
    } 
    catch (IOException e) 
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    FileOutputStream out = null;

    try 
    {
        out = new FileOutputStream(decryptedFile);
    } 
    catch (FileNotFoundException e) 
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try 
    {
        ImageIO.write(input,typeFile, out);
    } 
    catch (IOException e) 
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try 
    {
        cis.close();
    } 
    catch (IOException e) 
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


   }
4

1 に答える 1

1

私は同様の問題を抱えていました

import javax.sound.sampled.*;

対応するインポート (おそらく ImageIO) を見つけて、私に代わるものを見つける必要があります。

import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;

そうでない場合は、エラーを投稿してください。
また、インポートを切り替えるだけの問題ではなく、コードを新しいライブラリに移植する必要があったことに注意してください。

于 2012-06-25T20:46:04.363 に答える