Java I/O

How to read and parse CSV file


This tutorial shows how to read, parse and print out the values from a CSV file. Say we have a CSV file user-profile.csv where the user name, roll number, age, course name is stored, seperated by comma. Sample file data “Aman”,”A1234″,23,”B.Tech” “Rahul”,”A1235″,21,”B.Tech” “Ravi”,”A1236″,24,”B.Tech” “Maxwell”,”A1237″,23,”B.Tech” “Patrick”,”A1238″,26,”B.Tech” “John”,”A1239″,20,”B.Tech” Extracts the Roll Number and Course from above CVS file, and print it out. ... Read More »

What is Memory Leak & How can we avoid Memory Leak


Memory leak occurs when programmers create a memory in heap and forget to delete it. Memory leaks are particularly serious issues for programs which by definition never terminate. Usually developers talk about memory leaks but when you ask them what that means many have no idea. To prevent these situations, Lets discuss about memory lean in detail. Memory that is ... Read More »

Getting System Out to Write to a Particular File on System


This tutorial redirects the System.out to a file provided by the user. Steps to follow – 1. Create a file myconsole.txt. 2. Create a PrintStream which uses FileOutputStream 3. Set the System Out with PrintStream object. package com.jkoder; import; import; import; import; public class RedirectSystemOutput { public static void main(String[] args) throws FileNotFoundException { System.out.println("This output ... Read More »

Merge PDF Files in Java Using iText API


Java programme to merge different PDF files. This uses the iText API to read and merge PDF files What is iText? iText is a library that allows you to create and manipulate PDF documents. It enables developers looking to enhance web and other applications with dynamic PDF document generation and/or manipulation. You can create PDF documents from scratch with data ... Read More »

Java Utility to Decompress a Zip File In Java


In the previous example we have seen “How to compress files/folder in java“. Now we will focus on “Java Utility to Decompress a Zip File In Java” Java provides “” library to compress files/folder in zip format. Steps to follow – 1. Take folder/files path as input. 2. Read the zip file using ZipInputStream 3. Get the zip file list ... Read More »

Java Utility To Compress Files/Folder In Zip Format


Java provides “” library to compress files/folder in zip format. Steps to follow – 1. Take folder/files path as input. 2. Create a ZipOutputStream 3. Check if folder is empty or not. If the folder is empty, we will simply add the empty folder in zip, else we will read all the files and will add every files to zip. ... Read More »