.cab格式的文件包中有一个.txt格式的文件,如何用户JAVA代码解压缩出来啊?谢谢!
解决方案 »
- .jar 文件的打开问题
- 明明在*.java文件里有三个类,编译为什么就只生成两个对应的字节码文件,怪了!!高手请
- JAVA解压.Z文件
- 有谁做过用Java来控制扫描仪吗???
- 请教:如何播放wav格式的音频。。。。
- ~~怎样获取windows剪贴板中的bmp位图信息,并输出成bmp文件~~
- 我知道java慢,但是没想到java会这么慢,想看看高手们的做法
- 能帮我看看这个错误(有全代码,只99行)(swing)!
- 谁有“计算器”的源码呀!最好是手写的非ide编写的!谢谢
- 谁能帮我看看这段程序,拜托了
- Java中对JTABLE进行行的插入有什么简单方法?
- java中有类似sql中rpad这个方法的吗?
it accept a relative path to the resource, no matter if its in a cab or not.
something likegetResouece("/package/1.txt");and return you a DataInputStream.
you can the use the data input stream readLine method to get what you need.public DataInputStream getResource(String full_resource_name) throws java.io.IOException
{ InputStream is = getClass().getResourceAsStream(full_resource_name);
if(is == null)
throw new IOException("Unable to resolve resource name " + full_resource_name + " (file not found)"); BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buff = new byte[4096]; int len;
byte[] data =null; while ((len = bis.read(buff)) != -1)
{
baos.write(buff, 0, len);
} data = baos.toByteArray();
return new DataInputStream(new java.io.ByteArrayInputStream(data));
}