Monday, March 30, 2015

Generate the bar code image by itext

We can generate a bar code image by using the itext jar. Itext jar : http://sourceforge.net/projects/itext/ Download jar : http://sourceforge.net/projects/itext/files/latest/download sample code import com.itextpdf.text.pdf.BarcodePDF417; import java.awt.Color; import java.awt.image.BufferedImage; import...

Regular expression to extract the src tag details from given image tag or html source text

By using the regular expression we can extract the any data from the given input, here we are trying to get the src attribute value from the given image tag or html text data. Image 'src' attribute extract Regx: <img[^>]*src=[\\\"']([^\\\"^']*) sample code: import java.util.regex.Matcher; import...

Compare images are same by java

We can compare the given images are same or not by comparing the buffer data of the image. 1. Compare the image sizes are same or not. 2. Compare the binary data of two images are same or not. sample code : import java.awt.image.BufferedImage; import java.awt.image.DataBuffer; import java.io.File; import...

Saturday, March 28, 2015

Reverse elements in Array

Reverse all elements in array, traditional way how we use to do is get the array and iterate through the for loop and use swap logic to move to temporary array and get the result. But from > jdk 1.5 introduced reverse() in java.util.Collections which will reverse the order of the elements, all we...

find character uppercase/lowercase count from given text

Find the character upper/lower case occurrence count with simple single line code without iteration in java. int counta = text.split("(?=[a])").length - 1; This simple code will find all the lowercase character 'a' from the given text, change the regx for the uppercase . ex 'A'. sample test code /** ...

Monday, March 23, 2015

Thursday, March 19, 2015

Jfreechart servelt example

Prerequisites JDK 1.5 and above Jfreechart jar mysql connector jar To generate charts we can use jfrecharts which is open source and free. In this example i will show how to generate the jfreechart...

Tuesday, March 3, 2015

Monday, March 2, 2015

Generate PDF page as image

We can generate the image of pdf page by using the Pdf-renderer Simple class which generate the images file of given pdf file. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the...