zipfile

Progress Bar with unzipping of file

五迷三道 提交于 2019-12-04 15:12:25
问题 I am trying to update a progress bar with unzipping of file in the sd card. My unzipping works fine but the progress bar does not appear. Here is my code in mainactivity: private ProgressBar bar; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); bar = (ProgressBar) findViewById(R.id.progress); String zipFilename = Environment.getExternalStorageDirectory() + "path to my zip file in sd card"; String unzipLocation =

Java NIO ZipFileSystem: “zip END header not found” while creating file system

て烟熏妆下的殇ゞ 提交于 2019-12-04 13:02:23
I'm asking this here because googling this error only gives me hits on writing a zip file, while I'm only trying to read it. I have a unit test where I'm trying to test the following production code: Map<String, String> zipProps = new HashMap<>(); URI zipUri = URI.create("jar:file:" + itemZipPath.toString()); try (FileSystem zipfiles = FileSystems.newFileSystem(zipUri, zipProps)) { // do stuff... } catch (IOException e) { // log an error } However this fails on the line containing the try: java.util.zip.ZipError: zip END header not found at com.sun.nio.zipfs.ZipFileSystem.zerror(ZipFileSystem

extracting contents of ZipFile entries when read from byte[] (Java)

五迷三道 提交于 2019-12-04 11:06:22
I have a zip file whose contents are presented as byte[] but the original file object is not accessible . I want to read the contents of each of the entries. I am able to create a ZipInputStream from a ByteArrayInputStream of the bytes and can read the entries and their names. However I cannot see an easy way to extract the contents of each entry. (I have looked at Apache Commons but cannot see an easy way there either). UPDATE @Rich's code seems to solve the problem, thanks QUERY why do both examples have a multiplier of * 4 (128/512 and 1024*4) ? Rich Seller If you want to process nested zip

Create .zip in Python?

喜夏-厌秋 提交于 2019-12-04 08:01:00
问题 I'm trying to create a function in my script that zips the contents of a given source directory ( src ) to a zip file ( dst ). For example, zip('/path/to/dir', '/path/to/file.zip') , where /path/to/dir is a directory, and /path/to/file.zip doesn't exist yet. I do not want to zip the directory itself, this makes all the difference in my case. I want to zip the files (and subdirs) in the directory. This is what I'm trying: def zip(src, dst): zf = zipfile.ZipFile("%s.zip" % (dst), "w") for

Java: Zip file with non-static filename

落爺英雄遲暮 提交于 2019-12-04 07:01:44
问题 I found this ZipUtils class on this post: how to zip a folder itself using java I modified it so I could pass a zip file name. However, the only way it works is with a hardcoded static string. The zippedFile string is grabbed from the database. I have compared the dbZippedFile and hardcodedZippedFile and they are both identical... Perhaps there is an issue with using a non-static string with FileOutputStream? This problem only occurs when trying to zip directories (one file works fine). Does

Eclipse, Java: How to import a library in zip-format?

人走茶凉 提交于 2019-12-04 06:35:44
问题 Ok, this is basic, but it seems that the normal way of doing this doesn't work for me. I'm trying to import the jSSC library, for communication with serial ports etc. The newest library is jSSC-0.9.0-Release So, I've tried the following: Placed the zip file in the workspace and added it as "external jar" in the project properties -> java build path -> libraries. Then I try including something from the library: import jssc.SerialPortList; Error: The import jssc cannot be resolved Then I placed

Unzip buffer with Python?

别来无恙 提交于 2019-12-04 06:12:11
I have a buffer of bytes read from a library call and I would like to unzip the content which is a single text file. I tried with zlib , but I get this error: >>> import zlib >>> zlib.decompress(buffer) error: Error -3 while decompressing data: incorrect header check However with ZipFile it works, but I have to use a temporary file: import zipfile f = open('foo.zip', 'wb') f.write(buffer) f.close() z = ZipFile('foo.zip') z.extractall() z.close() with open('foo.txt', 'r') as f: uncompressed_buffer = f.read() Is it possible to use zlib and how can I avoid using a temporary file? Is it possible

Compression fails when using ionic zip

寵の児 提交于 2019-12-04 04:45:00
I am using the latest version of ionic zip version 1.9.1.8.I have set the property of ionic zip ParallelDeflateThreshold = 0 . The zipping mechanism was working perfectly for the past two months.Suddenly this stopped working.The zipping thread just hangs,ionic zip just created the tmp file and failed to create the zip file. I could easily reproduce this issue even with small file size. My analysis for this issue is as follows The issue was with the latest version of ionic zip, in this case the ionic zip hanged while creating the zip files. We noticed that, a couple of other users who uses this

How can I extract multiple zip files and read those csvs in R? [duplicate]

笑着哭i 提交于 2019-12-04 03:55:54
问题 This question already has answers here : Automate zip file reading in R (9 answers) Closed 2 years ago . I need to unzip multiple files at once and add it as a data frame in my R dashboard. I'm currently using this code: zipF<- "/Users/sahilverma13/Desktop/chat_data_2017-01-30_IST.zip" outDir<-"/Users/sahilverma13/Desktop" unzip(zipF,exdir=outDir) But I have to do it for every file separately. zipF <- list.files(pattern="*.zip") I tried using the wildcard but it doesn't work. Please help. 回答1

Zipping files in python

夙愿已清 提交于 2019-12-04 02:43:34
My Program runs smoothly but I want my files from ftp to be zip in my local drive My Problem : Only 1 file is being zipped after calling my main() function Here's my code: main import os import upload import download import zipfile import ConfigParser import ftputil def main(): #create a folder Temp on d drive for later use path = r'D:\Temp' os.mkdir(path) #parse all the values at config.ini file config = ConfigParser.ConfigParser() config.readfp(open('config.ini')) server = config.get('main', 'Server') username = config.get('main', 'Username') password = config.get('main', 'Password') uploads