Posts

Showing posts from April, 2016

Regular Expression Powerfull sample in java

We can use regular expression and to do large set of works as simple and single line code . In this example i will show you how the regular expression play a vital stage . I want to read a file and insert a new line (\n) at every 100 th character in that file content and write those changes in another file. Normally what i did first is written a code to read file line by line and written a sample piece of code to read position and insert the new line in that particular position then written in new file. Instead for write separate function i write an replaceAll with regular expression. The sample code given below, package com.shinnedhawks; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class REPower {     public static void main(String[] args) {         new REPower().replace();   ...