How to write a scheduling job in java
September 8th, 2009No Comments | Filed Under: Tutorials
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 jobs; jobs whose tasks are defined as standard Java components or EJBs. The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering.
http://www.opensymphony.com/quartz/
2. java batch process
If you are looking for writing java batch process you can find nice sample program at below link
http://www.java-tips.org/other-api-tips/jdbc/how-to-exceute-a-batch-process-from-preparedstat-2.html
3. java job triggering
If you need triggering point from java then you might want to take look at Timer class in java.
http://java.sun.com/j2se/1.4.2/docs/api/index.html
How to remove white-space from a String
September 2nd, 2009No Comments | Filed Under: Tutorials
/*** replace multiple whitespaces between words with single blank */
String value = before.trim().replaceAll("[ ][ ]*", " ");
or
//before : hi how are you
//after: hi how are you
/* remove leading whitespace */
//before : hi how are you
//after: hi how are you
/* remove trailing whitespace */
//before : hi how are you
//after: hi how are you
/** Trims all white spaces from an input string. */
String[] trimString = s.trim().split(" ");
String trimmedString = "";
for (int i = 0; i < trimString.length; i++){
trimmedString = trimmedString + trimString[i];
}
return trimmedString;
}
Display specific length string without truncating word in Java
June 25th, 2009No Comments | Filed Under: Tutorials
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.
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 str;
}