3
我遵循此topic,它完美的作品。這裏的功能爲文件下載器創建資源如何讓用戶使用vaadin文件下載器下載zip文件
private StreamResource createResource() {
return new StreamResource(new StreamSource() {
@Override
public InputStream getStream() {
String text = "My image";
BufferedImage bi = new BufferedImage(100, 30, BufferedImage.TYPE_3BYTE_BGR);
bi.getGraphics().drawChars(text.toCharArray(), 0, text.length(), 10, 20);
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(bi, "png", bos);
return new ByteArrayInputStream(bos.toByteArray());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}, "myImage.png");
}
但我不知道如何使它創建一個zip文件的資源。我是否需要創建許多資源?謝謝
解決方案壓縮-1565076.html)教程「壓縮和歸檔ZIP文件中的數據」部分。 –
如果你想出了一個解決方案,請分享它作爲答案。 –
誰是「他們」*? – specializt