-1

我有一个代码来解码一个字符串,如下所示:

  public static void main(String[] args) throws IOException {
    String base64="anybase64value"       
    byte[] bytes = Base64.decodeBase64(base64);
    String tempDir = System.getProperty("java.io.tmpdir");
    System.out.println(System.getProperty("java.io.tmpdir"));
    String testFileName = "/tmp/" + "base64.xlsx";

    FileOutputStream fos = new FileOutputStream(new File(testFileName));
    IOUtils.write(bytes, fos);
    System.out.println("Wrote " + bytes.length + " bytes to: " + testFileName);
}

但是当我运行它时会抛出一个错误:

The method write(byte[], OutputStream) in the type IOUtils is not applicable for the arguments (byte[], File)
The method close() is undefined for the type File
4

1 回答 1

1

发生这种情况是因为您试图在 rt.jar 中调用write方法sun.misc.IOUtils。您需要使用 import org.apache.commons.io.IOUtils。可能是错误的导入。

于 2013-08-28T07:52:16.247 回答