问个问题,我想把字符串压缩成.zip,然后再解压.zip,解压之后是一个.txt文件。这个过程中,我不想先把字符串写入.txt,应该怎样实现?大家帮忙给段代码,谢谢!
解决方案 »
- insert "}" to complete Block 找不出来实在。。。。括号匹配了呀~哪位高手帮助看看
- 关于html中文乱码的一个怪异问题
- 关于在struts2的ACTION中使用数据库查询结果集的问题
- 请教一个过滤器控制权限的问题?????
- xfire发布的webservice可以用表单通过post方式直接调用么?现在版面ms被我霸占了^_^
- html:checkbox标签哪个属性可以让他默认选中
- 如何在Spring配置文件中设置MySQL 的max_allowed_packet属性???
- Tomcat 5.5+mysql创建数据池成功,但是插入中文乱码,各种方法不能解决的问题
- 乱码了?快来救救我呀!!!
- 100分请教现在java怎么做项目的?用那种模式?先谢后送分
- 自动生成查询界面之后,如何通用一个javascript,取得参数并发送请求?现在弄的有点伤神!请求支援!
- 这是什么错误 怎么解决?
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;public class AddFileToZip { public static void main(String[] args) {
appendFileToZip("test.zip");
} public static void appendFileToZip(String zipFileName) {
try {
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
zipFileName));
// for put directory
out.putNextEntry(new ZipEntry("/"));
// for put file
out.putNextEntry(new ZipEntry("test1.txt"));
String stringIntoZipTxt = "This is the string put into the newly crreated text in the zip...";
byte[] bs = stringIntoZipTxt.getBytes();
out.write(bs); System.out.println("Zip Done!");
out.close(); } catch (Exception e) {
}
}}