course not, think about serialization can make it easy for us to touch the object's private data domain, this is how dangerous loophole! To summarize, there are four types of class objects in the JDK that are absolutely not serializable.(1) Classes that are too dependent on the underlying implementation (too closely tied to native code). Like Java.util.zip.Deflater.(2) The state of an object depends on the inside of the virtual machine and the constantly changing runtime environment. Like Java.
How to Use Python to compress and decompress zip files
This article mainly introduces how to use Python to compress and decompress zip files. It mainly uses the zipfile package. For more information, see
Python zipfile provides a very convenient way to compress and decompress zip files.
For example, in the directory where The py script is located, there are the following files:
The Code is as follows:
Reada
Find these kinds of methods on the Internet, feel good, collect them, convenient for everyone to use
JDK comes with the package java.util.zip.ZipOutputStream, shortcomings, file (folder) name with Chinese, garbled problem occurs, the implementation code is as follows
/*** Function: Compress all files in SourceDir directory into zip format, save as specified zip file *@paramSourceDir If it is a directory, Eg:d:\\myeclipse\\first\\testfile, all files under the compressed directory; *
A simple zip compression decompression Tool class written using Java base classes
Copy Code code as follows:
Package sun.net.helper;
Import java.io.*;Import Java.util.logging.Logger;Import java.util.zip.*;public class Ziputil {Private final static Logger Logger = Logger.getlogger (ZipUtil.class.getName ());private static final int BUFFER = 1024*10;
/*** Compress the specified directory into a zip file with the same name as the directory, and customize the compression path* @para
Decompression in the JAVA JDK does not seem to decompress our manually compressed RAR files, only the JDK API compressed RAR
So come up with the following WinRAR command line decompression
Package edu.nwpu.vcampus.util; Import Java.io.File; public class Ziputil {public static final String Winrarpath = ' C://program files//winrar//winrar.exe '; public static bool EAN unzip (String ZipFile) {Boolean bool = false; File F=new file (
>>>import ZipFile, OSInfomation for ZIP file>>>zipfilehandle = ZipFile. ZipFile (' example.zip ')//create zip file handle>>>zipfilehandle.namelist ()//return All files and Directorys in the zip file>>>spaminfo = zipfilehandle.getinfo (' filename ')//return A object of file in the zip file>>>spaminfo.filename//return filename>>>spaminfo.file_size//return File Orig
Article transferred from: http://www.abcjava.com/html/JAVA/JAVAjichu/2009/1018/1080.html
Http://www.xcoder.cn
When multiple files are transmitted over the network, it will take a lot of time and consume more computer system resources. If we package multiple files and transfer them again, it will save a lot of computer resources. Here, I will show you how to read, decompress, and create ZIP files. Of course, here is a brief introduction. You need to implement the ZIP file in many details. For Ja
calculation, 1 for the current position as the origin. 2 means that the end of the file is calculated as the origin. Note that if the file is opened in a or a + mode, the file action tag is automatically returned to the end of the file each time the write operation is made. F.truncate ([size]) #把文件裁成规定的大小, the default is the location that is cropped to the current file action tag.
When you read a file, Python remembers its location in the file, and if you still need to read from scratch for the
Python Operation zip fileNeed to use to ZipFile moduleRead zip fileAny zip file, I use Bb.zip here, is a folder BB, there is a file aa.txt.Import ZipFile# default mode R, read Azip= ZipFile. ZipFile (' Bb.zip ')# [' bb/', ' bb/aa.txt ']# return all folders and files print (azip.namelist ()) # # returns the zip filename
:" +zipdest); If this is the/end, it is proved that the user entered a directory, which requires a filename if (Zipdest.endswith (File.separator)) {zipdest+=srcfile.getname () +su
Ffix; else {//If the compressed file name does not end with Zip/tar, then add the suffix if (!zipdest.endswith (suffix)) {zipdest +=su
Ffix; }///If the user chooses ZIP, Ziputil is used to compress if (type = = Antzipactivity.type_zip) {Ziputil zipp = new Ziputil ();
Zipp.dozip (Srcpath, zipdest);
Python-specific databases in Python allow Python programmers to easily create a complete GUI with full function keys, this article provides the source code of the complete memory pool management program and test program for managing memory in a Python-specific database for your reference!
Just like Python and wxWidgets, a specific Python database is also an open-source software with excellent cross-platform capabilities in Russia, supports running on 32-bit windows, most Unix or Unix-like system
When you open the file with the image browsing tool, you can see that the image is surrounded by a circle of single pixels, and the black pixel is that we use draw9patch. after we put the image in the Res/drawable folder and compile it on Android, decompress the APK package. You can see that although the Res/logs file is actually usableProgramTo simulate this process, you can directly import the .9.png image, and then automatically generate the edited .9.png image.
Upload images, and finally D
Os.walk () function is passed in a string value, which is the path to a folder. You can have a forOs.walk () traverses the directory tree, returning 3 values:1. The name of the folder that is currently traversed;2. A list of subfolders in the current folder;3. The list of files in the current folder.Compression# New compressed file is opened in write mode, and write mode erases all the original contents in the zip file# The second argument passed in ' a ' is opened in Add mode, the file is adde
From a simple point of view, the ZIP format is a good choice, and Python's support for the ZIP format is simple enough to be useful.
1) Simple application
If you just want to use Python for compression and decompression, then you don't have to go through the document, and here's a simple usage that you can see.
Import ZipFile
f = zipfile. ZipFile (' Filename.zi
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.