List or display contents of compressed or zipped file in java (example)

Given a zipped or compressed file in java. We would like to display or list the contents of zipped file. We will display the name and size of uncompressed files. Program – list or display contents of zipped /compressed file in java package org.learn; import java.io.IOException; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class DisplayZipContents {… Read More »

Create compress /zip file in java (ZipOutputStream class /example)

Given the input files in java, create zip or compress files using ZipOutputStream class . Java framework has provided couple of classes to create a zip & compress file. ZipOutputStream: ZipOutputStream class implements an output stream filter for writing files in ZIP file format. ZipEntry: ZipEntry class represents a ZIP file entry. e.g. If we want to… Read More »

Write or redirect standard output error stream to a file in java

We write error of an application(s) to standard error stream using System.err.print*. System.err.println(“1. Write error to a file”); We would like to redirect the application errors to a file.  e.g. System.err.println(“1. Write error to a file”) should be written to a file. We would like to set output stream, so that all errors will be… Read More »

Convert String to Integer in java (with example)

Given an String in java, we would like convert String to integer. We can convert String to integer using following methods. Convert String to integer using Integer.parseInt. Convert String to integer using Integer.valueOf. Convert String to integer using Integer constructor. Program – convert String to Integer in java (with example) package org.learn; public class ConvertStringToInt { public… Read More »

Page 5 of 43« First...34567...102030...Last »