

You can see it if your hard drive was formatted with NTFS by opening My Computer and then taking a look at the details section on the lower left. In addition to the compressed folders feature, Windows XP supports another type of compression if your hard drive is formatted as an NTFS volume. To add a password, open the compressed folder and select File, Add a Password. If you forget it, your data stored in the compressed folder will be lost forever. You should be careful when using this feature, however. To uncompress them (or return them to their original state) drag them out of the compressed folder.Ĭompressed folders even support a password option, allowing you to use them as a place to store sensitive information. To compress files (or make them smaller) simply drag them into this folder. Your new compressed folder will have a zipper on its icon to indicate that any files contained in it are compressed. Type a name for the compressed folder and press enter. Open that folder, then select File, New, Compressed (zipped) folder. To create a compressed folder, open My Computer and locate the folder where you want to create the compressed folder (also known as an archive). In the past, utilities such as Winzip were used for this purpose, but Windows XP has a built in compression utility that does the same job. String zipDirName = "/Users/pankaj/tmp.One way to store more data when you are low on hard drive space is by using compression to make the files and folders you already have on the drive take up less space. String zipFileName = "/Users/pankaj/sitemap.zip" įile dir = new File("/Users/pankaj/tmp") Here is the java program showing how to zip a single file or zip a folder in java.įile file = new File("/Users/pankaj/sitemap.xml") We need to add a ZipEntry for each file and use FileInputStream to read the content of the source file to the ZipEntry corresponding to that file. Then process each one of them separately. Zipping a directory is little tricky, first we need to get the files list as absolute path. Once we are done writing, we need to close ZipEntry and release all the resources. Then we add a new ZipEntry to the ZipOutputStream and use FileInputStream to read the source file to ZipOutputStream object. Creating a zip archive for a single file is very easy, we need to create a ZipOutputStream object from the FileOutputStream object of destination file.
