Android getEncryptedData(String)调用无效的新字符串(String)构造函数-Findbugs

Android getEncryptedData(String)调用无效的新字符串(String)构造函数-Findbugs,android,findbugs,spotbugs,Android,Findbugs,Spotbugs,我正在尝试将byte[]转换为String。它工作正常。但是FindBugs在我的代码片段中指出了一个小问题 代码片段: //Encrypt the data withe public key. Cipher cipher = Cipher.getInstance(TRASFORMATION); cipher.init(Cipher.ENCRYPT_MODE, publicKey); byte[] encryptedBytes =

我正在尝试将byte[]转换为String。它工作正常。但是FindBugs在我的代码片段中指出了一个小问题

代码片段:

        //Encrypt the data withe public key.
        Cipher cipher = Cipher.getInstance(TRASFORMATION);
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);
        byte[] encryptedBytes = cipher.doFinal(data.getBytes(StandardCharsets.UTF_8));
        encryptedData = new String(Base64.encodeToString(encryptedBytes, Base64.DEFAULT));
Findbug报告:

        //Encrypt the data withe public key.
        Cipher cipher = Cipher.getInstance(TRASFORMATION);
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);
        byte[] encryptedBytes = cipher.doFinal(data.getBytes(StandardCharsets.UTF_8));
        encryptedData = new String(Base64.encodeToString(encryptedBytes, Base64.DEFAULT));
getEncryptedData(String)调用无效的新字符串(String)构造函数

我在哪一行收到此错误?

encryptedData = new String(Base64.encodeToString(encryptedBytes, Base64.DEFAULT));
有人能告诉我这到底是什么吗?我们如何解决这个问题呢?

替换

encryptedData = new String(Base64.encodeToString(encryptedBytes, Base64.DEFAULT));

“编码到字符串”已返回该字符串