Skip to main content

Posts

Showing posts from 2016

How to convert a CSV file to XLSX

I wrote this utility for a friend of mine who wanted to convert large (~50MB) CSV files to XLSX. The CSV files had comma "," as a delimiter. I have used apache poi utility in this program. https://www.apache.org/dyn/closer.lua/poi/release/RELEASE-NOTES.txt This code uses SXSSFWorkbook class. The SXSSFWorkbook class uses "BigGridDemo" strategy, where only portions being processed are kept in memory. There are temporary files created which store the rest of the temporary data. setCompressTempFiles() method allows these temp files to be compressed. The size of these files can get quite large. The data to be converted was UTF-8 encoded data. So, we are using  OutputStreamWriter, where we specify the encoding of the data. If you do not need the encoding, just remove that parameter from the constructor call of OutputStreamWriter. The system where this ran, supported Java 7, so have not used features in java 8, such as try with exceptions. import java.io.*; im

Interview Task: Java exercise to test basic Java skills

Here is a problem to test following basic Java skills, with increasing difficulty. Depending on what skills are expected from you. 1. OOPS concepts 2. Code Design 3.  Knowledge of Java classes 4. Collections 5. J2EE Interview Tasks Task 1 Create an application that maintains information of all students in a class. The information of each student includes Name, Age and Roll number. The application should be able to do the following, through a console: (No need for UI) 1. Add a new student information 2. Delete a student information 3. Edit Student information -- Roll number should not be editable 4. List all students in a class --While evaluating the solution, check what are the Interfaces, abstract classes are created and the reasons to do so. Which collection is used to store the list of students. How do you ensure a student is not added twice. Task 2 Now functionality that will allow users to be sorted alphabetically by Name. Also add another functional