Java method for spliting a camelcase string

This Java method accepts a camel case string, and returns a linked list of splitted strings. It has been designed to handle various kinds of different cases and fully tested and good to use. Handling camel case in Java involves a lot of styles, this methods can handle the following cases: Regular camel case names, … Read more

FileOutputStream vs. FileWriter

When we use Java to write something to a file, we can do it in the following two ways. One uses FileOutputStream, the other uses FileWriter. Using FileOutputStream: File fout = new File(file_location_string); FileOutputStream fos = new FileOutputStream(fout); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos)); out.write("something");File fout = new File(file_location_string); FileOutputStream fos = new FileOutputStream(fout); BufferedWriter … Read more

Eclipse RCP Tutorial: Eclipse Rich Client Application with a View

Eclipse RCP provides an easy way to create desktop applications with industry standards. Once you understand how the framework works, it’s very straightforward to add more views, perspectives, etc. This article shows how to create a simple rich client application with a view by using development wizard. It also explains the role of each file … Read more

Java append/add content to an existing file

Replace vs Append/Add If you want your code to create a new file and erase previous existing file, FileWriter can simply take it place. To replace all content in an existing file, use this: FileWriter fstream = new FileWriter(loc);FileWriter fstream = new FileWriter(loc); The code above will delete the existing file if it’s name is … Read more

How to Write a File Line by Line in Java?

This post summarizes the classes that can be used to write a file. 1. FileOutputStream public static void writeFile1() throws IOException { File fout = new File("out.txt"); FileOutputStream fos = new FileOutputStream(fout);   BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));   for (int i = 0; i < 10; i++) { bw.write("something"); bw.newLine(); }   bw.close(); … Read more

Java read a file line by line – How Many Ways?

Processing a text file line by line is a common thing programmers do. There are many related classes in the Java I/O package and this may get confusing. This post shows 4 different ways of reading a file line by line in Java. 1. FileInputStream and BufferedReader private static void readFile1(File fin) throws IOException { … Read more