Posts Under 'Tutorials'

How to write a scheduling job in java

1. Quartz Quartz is a full-featured, open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application – from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of […]

Read more »


How to remove white-space from a String

/*** replace multiple whitespaces between words with single blank */ String before=" hi how are you "; String value = before.trim().replaceAll("[ ][ ]*", " "); or String value = before.replaceAll("\\b\\s{2,}\\b", " "); //before : hi how are you //after: hi how are you /* remove leading whitespace */ String value= before.replaceAll("^\\s+", ""); //before : hi […]

Read more »


Display specific length string without truncating word in Java

If you want to display substring of text and don’t want to truncate word in a substring, then you can use below method to fulfill your requirement. public static String textSubString(String text, int start, int end){ String str=""; int limit=0; limit=end; if(text.length()!=0 && text!=""){ String substr=text.substring(end,end+1); if(substr!=""){ while(!substr.equals("")){ substr=text.substring(limit,++limit); substr=substr.trim(); } } str=text.substring(start,limit); } return […]

Read more »


Java method similar to nl2br in PHP

Below Java method will work same as PHP function nl2br public static String nl2br( String text){ return text.replaceAll("\n","<br />"); }

Read more »


Directory index forbidden by Options directive

I was going through error log and saw this error in error log file. To solve this problem, In /etc/httpd/conf.d you will see a file entitled welcome.conf It looks like this: <LocationMatch “^/+$”> Options -Indexes ErrorDocument 403 /error/noindex.html </LocationMatch> Change it to this: <LocationMatch “^/+$”> Options Indexes ErrorDocument 403 /error/noindex.html </LocationMatch> Just remove the hyppen(-) […]

Read more »