<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4586519034017659067</id><updated>2012-02-16T12:45:22.833-08:00</updated><category term='Hashtable'/><category term='String'/><category term='XML'/><category term='Collection'/><category term='Calendar'/><category term='Excel'/><title type='text'>Java Snippets</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-1242376796356418696</id><published>2011-05-13T13:29:00.000-07:00</published><updated>2011-05-13T13:29:02.725-07:00</updated><title type='text'>Surround Strings with Quotes</title><content type='html'>&lt;p&gt;The following &lt;b&gt;Java &lt;/b&gt;class adds quotes to a string depending on&lt;br /&gt;whether it is a number or not. The class relies on the NumberFormatException to determine whether a string is a number.&lt;br /&gt;The added benefit is that single quotes in strings are escaped with a backslash.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;public class Util {&lt;br /&gt; public static String escapeQuotes( String s ){&lt;br /&gt;      return s.replaceAll("'","\\\\'");&lt;br /&gt; }&lt;br /&gt; private static boolean isNumber(String str){&lt;br /&gt;  try{&lt;br /&gt;   Integer.parseInt(str);&lt;br /&gt;   return true;&lt;br /&gt;  }&lt;br /&gt;  catch(NumberFormatException e){&lt;br /&gt;   return false;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; private static boolean isEmpty(String str){&lt;br /&gt;  return !(str.length()&gt;0);&lt;br /&gt; }&lt;br /&gt; public static String addQuotes(String str) {&lt;br /&gt;  str = str.trim();&lt;br /&gt;  if(!isEmpty(str)){&lt;br /&gt;   if(isNumber(str))&lt;br /&gt;    return str;&lt;br /&gt;   else&lt;br /&gt;    return "'"+ escapeQuotes(str)+"'";&lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;   return null;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public static String deleteLastCharacter(String str){&lt;br /&gt;   return str.substring(0, str.length()-1);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;This class could be used as a helper class to construct a valid sql statement.&lt;br /&gt;Here is code for a method that takes file contents and adds single quotes around Strings leaving numbers intact:&lt;br /&gt;&lt;pre&gt;public static void convert (BufferedReader in, PrintWriter out)&lt;br /&gt;   throws IOException {&lt;br /&gt; String separator  = System.getProperty("line.separator");&lt;br /&gt; String delimiter  = ",";&lt;br /&gt; for (String line = in.readLine(); line != null; line = in.readLine()) {&lt;br /&gt;  line = line.trim();&lt;br /&gt;  if (line.length() == 0) {&lt;br /&gt;   continue;&lt;br /&gt;  }&lt;br /&gt;  StringTokenizer st = new StringTokenizer(line, delimiter, false);&lt;br /&gt;  String outLine ="";&lt;br /&gt;  while(st.hasMoreTokens()) {&lt;br /&gt;   String token  = st.nextToken();&lt;br /&gt;   outLine += Util.addQuotes(token) +",";&lt;br /&gt;  }&lt;br /&gt;  outLine = Util.deleteLastCharacter(outLine);&lt;br /&gt;  out.print(outLine + separator);&lt;br /&gt;  }&lt;br /&gt; in.close();&lt;br /&gt; out.close();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you can see, this method accepts 2 arguments, &lt;i&gt;BufferedReader &lt;/i&gt;and &lt;i&gt;PrintWriter&lt;/i&gt;. It takes each line in a file and splits it into&lt;br /&gt;comma-separated tokens. Then, addQuotes() method is called on each token. The line is assembled again and written to a PrintWriter.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-1242376796356418696?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/1242376796356418696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/surround-strings-with-quotes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/1242376796356418696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/1242376796356418696'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/surround-strings-with-quotes.html' title='Surround Strings with Quotes'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-4184257967401341493</id><published>2011-05-13T13:27:00.001-07:00</published><updated>2011-05-13T13:27:47.293-07:00</updated><title type='text'>Java Text File Splitter Class</title><content type='html'>&lt;p&gt;Here is a Java class that splits a text file into multiple files using a supplied string as a separator.&lt;br /&gt;&lt;p&gt;It accepts two arguments in the constructor: a path to the file, and a token to be used for separation.&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Usage example: &lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;TextFileSplitter tfs = new TextFileSplitter('myfile.txt', 'Section');&lt;br /&gt;tfs.run();&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;It will create a sub-directory in the same directory as the file where it will place the resulting files.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This is a very basic version that does not throw any exceptions.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import java.io.BufferedReader;&lt;br /&gt;import java.io.BufferedWriter;&lt;br /&gt;import java.io.File;&lt;br /&gt;import java.io.FileInputStream;&lt;br /&gt;import java.io.FileWriter;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import java.io.InputStreamReader;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import java.util.Iterator;&lt;br /&gt;&lt;br /&gt;public class TextFileSplitter {&lt;br /&gt;&lt;br /&gt; private static String fullPath ;&lt;br /&gt; private static String token;&lt;br /&gt;&lt;br /&gt; public TextFileSplitter(String path, String token) {&lt;br /&gt;  this.fullPath = path;&lt;br /&gt;  this.token = token;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; public void run(){&lt;br /&gt;&lt;br /&gt;  ArrayList al = splitIntoTokens(fullPath, token);&lt;br /&gt;&lt;br /&gt;  if(al.size()==0){&lt;br /&gt;   return;&lt;br /&gt;  }&lt;br /&gt;  String dir = getDirectoryFromFileName(fullPath);&lt;br /&gt;&lt;br /&gt;  int pageIndex =1;&lt;br /&gt;  Iterator iter = al.listIterator();&lt;br /&gt;  String name = getFileName(fullPath);&lt;br /&gt;&lt;br /&gt;  while(iter.hasNext()){&lt;br /&gt;   String str = (String)iter.next();&lt;br /&gt;   String fileName = dir+"\\"+ name + "_"+ pageIndex + ".txt";&lt;br /&gt;   try {&lt;br /&gt;    System.out.println(fileName);&lt;br /&gt;    writeFile(fileName, str);&lt;br /&gt;   }&lt;br /&gt;   catch (IOException e) {&lt;br /&gt;    e.printStackTrace();&lt;br /&gt;   }&lt;br /&gt;   pageIndex++;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; private String getFileName(String path){&lt;br /&gt;&lt;br /&gt;  String fileName = null;&lt;br /&gt;  String separator = File.separator;&lt;br /&gt;&lt;br /&gt;  int pos = path.lastIndexOf(separator);&lt;br /&gt;  int pos2 = path.lastIndexOf(".");&lt;br /&gt;&lt;br /&gt;  if(pos2&gt;-1)&lt;br /&gt;   fileName =path.substring(pos+1, pos2);&lt;br /&gt;  else&lt;br /&gt;   fileName =path.substring(pos+1);&lt;br /&gt;&lt;br /&gt;  return fileName;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private String getDirectoryFromFileName(String fname) {&lt;br /&gt;&lt;br /&gt;  String parent =  (new File(fname).getParent());&lt;br /&gt;&lt;br /&gt;  String name = getFileName(fname);&lt;br /&gt;&lt;br /&gt;  String dirPath = parent+"\\" + name;&lt;br /&gt;&lt;br /&gt;  File dir = new File(dirPath);&lt;br /&gt;&lt;br /&gt;  if(!dir.exists()){&lt;br /&gt;   boolean success = dir.mkdir();&lt;br /&gt;   if (!success) {&lt;br /&gt;    System.out.println("Directory creation failed");&lt;br /&gt;    return null;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;  return dirPath;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; private  void writeFile(String fname, String str) throws IOException{&lt;br /&gt;  BufferedWriter out=new BufferedWriter ( new FileWriter(fname));&lt;br /&gt;  out.write(str);&lt;br /&gt;  out.close();&lt;br /&gt; }&lt;br /&gt; &lt;span class=green&gt;&lt;br /&gt; //splits a file into an ArrayList of strings using the separator passed&lt;br /&gt; &lt;/span&gt;&lt;br /&gt; private ArrayList splitIntoTokens(String fname, String token){&lt;br /&gt;  String line;&lt;br /&gt;  StringBuffer sb = new StringBuffer();&lt;br /&gt;  ArrayList al = new ArrayList();&lt;br /&gt;  String lineSeparator =  System.getProperty("line.separator");&lt;br /&gt;  try {&lt;br /&gt;   FileInputStream fis = new FileInputStream(fname);&lt;br /&gt;            BufferedReader reader=&lt;br /&gt;              new BufferedReader&lt;br /&gt;                (new InputStreamReader(fis));&lt;br /&gt;&lt;br /&gt;            while((line = reader.readLine()) != null) {&lt;br /&gt;    if((line.indexOf(token))&gt;-1){&lt;br /&gt;     al.add(sb.toString());&lt;br /&gt;     sb = new StringBuffer();&lt;br /&gt;    }&lt;br /&gt;    sb.append(line + lineSeparator);&lt;br /&gt;   }&lt;br /&gt;           &lt;span class=green&gt; //add last section&lt;/span&gt;&lt;br /&gt;            al.add(sb.toString());&lt;br /&gt;   reader.close();&lt;br /&gt;  }&lt;br /&gt;  catch (IOException e) {&lt;br /&gt;            System.err.println("*** IOexception ***" + e.getMessage());&lt;br /&gt;  }&lt;br /&gt;  return al;&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-4184257967401341493?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/4184257967401341493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/java-text-file-splitter-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4184257967401341493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4184257967401341493'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/java-text-file-splitter-class.html' title='Java Text File Splitter Class'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-7023769807930657702</id><published>2011-05-13T13:25:00.001-07:00</published><updated>2011-05-13T13:25:53.798-07:00</updated><title type='text'>List Files in a Directory</title><content type='html'>&lt;p&gt;The following Java example returns an ArrayList of only those files that have a .csv extension.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;public static ArrayList listFiles(String dirName) {&lt;br /&gt; ArrayList al = new ArrayList();&lt;br /&gt; File dir = new File(dirName);&lt;br /&gt;&lt;br /&gt; String[] children = dir.list(&lt;i&gt;filter&lt;/i&gt;);&lt;br /&gt; if (children == null) {&lt;br /&gt;&lt;span class=comment&gt;//Either dir does not exist or is not a directory&lt;/span&gt;&lt;br /&gt;  }&lt;br /&gt; else {&lt;br /&gt;  for (int i = 0; i &lt; children.length; i++) {&lt;br /&gt;  &lt;span class=comment&gt;// Add the file name to ArrayList&lt;/span&gt;&lt;br /&gt;   al.add(children[i]);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;  return al;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=comment&gt;// Create an an inner class that implements the FilenameFilter interface.&lt;/span&gt;&lt;br /&gt;    static FilenameFilter &lt;i&gt;filter&lt;/i&gt; = new FilenameFilter() {&lt;br /&gt;        public boolean accept(File dir, String name) {&lt;br /&gt;            return name.endsWith("csv");&lt;br /&gt;        }&lt;br /&gt;    };&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;To list all files in the directory use the &lt;b&gt;list()&lt;/b&gt; method without arguments.&lt;br /&gt;&lt;p&gt;The code is based on the &lt;a href='http://javaalmanac.com/egs/java.io/GetFiles.html?l=rel'&gt;Java Developers Almanac &lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-7023769807930657702?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/7023769807930657702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/list-files-in-directory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/7023769807930657702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/7023769807930657702'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/list-files-in-directory.html' title='List Files in a Directory'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-7475979546150431463</id><published>2011-05-13T13:24:00.001-07:00</published><updated>2011-05-13T13:24:50.692-07:00</updated><title type='text'>Read File Contents into Java ArrayList</title><content type='html'>&lt;p&gt;The following method reads file contents into an &lt;b&gt;ArrayList&lt;/b&gt;. Each element of the ArrayList will contain a line from the file.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;public ArrayList readFile(String fname){&lt;br /&gt;    String line;&lt;br /&gt;    StringBuffer sb = new StringBuffer();&lt;br /&gt;    ArrayList al = new ArrayList();&lt;br /&gt;    try {&lt;br /&gt;     FileInputStream fis = new FileInputStream(fname);&lt;br /&gt;        BufferedReader reader=&lt;br /&gt;          new BufferedReader&lt;br /&gt;            (new InputStreamReader(fis));&lt;br /&gt;        while((line = reader.readLine()) != null) {&lt;br /&gt;   al.add(line);&lt;br /&gt;  }&lt;br /&gt;        reader.close();&lt;br /&gt; }&lt;br /&gt; catch (IOException e) {&lt;br /&gt;     System.err.println("*** IOexception ***" + e.getMessage());&lt;br /&gt; }&lt;br /&gt; return al;&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-7475979546150431463?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/7475979546150431463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/read-file-contents-into-java-arraylist.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/7475979546150431463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/7475979546150431463'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/read-file-contents-into-java-arraylist.html' title='Read File Contents into Java ArrayList'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-4573012355209475089</id><published>2011-05-13T13:23:00.001-07:00</published><updated>2011-05-13T13:23:53.793-07:00</updated><title type='text'>Get File Name without extension from Its Path</title><content type='html'>&lt;p&gt;The following Java method returns a file name without extension from its path.&lt;br /&gt;&lt;br /&gt;&lt;pre class=codeblock&gt;public static String getFileName(String path){&lt;br /&gt;&lt;br /&gt; String fileName = null;&lt;br /&gt; String separator = File.separator;&lt;br /&gt;&lt;br /&gt; int pos = path.lastIndexOf(separator);&lt;br /&gt; int pos2 = path.lastIndexOf(".");&lt;br /&gt;&lt;br /&gt; if(pos2&gt;-1)&lt;br /&gt;  fileName =path.substring(pos+1, pos2);&lt;br /&gt; else&lt;br /&gt;  fileName =path.substring(pos+1);&lt;br /&gt;&lt;br /&gt; return fileName;&lt;br /&gt;}&lt;br /&gt; &lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-4573012355209475089?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/4573012355209475089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/get-file-name-without-extension-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4573012355209475089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4573012355209475089'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/get-file-name-without-extension-from.html' title='Get File Name without extension from Its Path'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-4698424170892651436</id><published>2011-05-13T13:21:00.000-07:00</published><updated>2011-05-13T13:21:59.486-07:00</updated><title type='text'>Create Sub-Directory From File Name in Java</title><content type='html'>&lt;b&gt;Description:&lt;/b&gt;&lt;br /&gt;You have a file name and you need to create a new directory in the folder where the file resides.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Solution: &lt;/b&gt;&lt;br /&gt;&lt;blockquote&gt;The following method creates a new directory in the same directory as the file. If the directory exists already, it does nothing.&lt;br /&gt;In other words, it makes sure the directory is there.&lt;br /&gt;It accepts two strings as arguments, file name and sub-directory name.&lt;br /&gt;&lt;pre&gt;boolean &lt;b&gt; createDirectory&lt;/b&gt; (String fname, String dirName) {&lt;br /&gt; &lt;span class="comment"&gt;//get the path to the parent directory&lt;/span&gt;&lt;br /&gt; String parent =  (new File(fname).getParent());&lt;br /&gt; &lt;span class="comment"&gt;//construct a new directory path&lt;/span&gt;&lt;br /&gt; String dirPath = parent+"\\" + dirName;&lt;br /&gt;&lt;br /&gt; File dir = new File(dirPath);&lt;br /&gt;&lt;br /&gt; if(!dir.exists()){&lt;br /&gt;  boolean success = dir.mkdir();&lt;br /&gt;  if (!success) {&lt;br /&gt;   System.out.println("Directory creation failed");&lt;br /&gt;   return false;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;A variation of the above method is the one that returns the path to the sub-directory:&lt;br /&gt;&lt;pre&gt;public static String getDirectory(String fname, String dirName) {&lt;br /&gt;&lt;br /&gt;  String parent =  (new File(fname).getParent());&lt;br /&gt;  String dirPath = parent+"\\" + dirName;&lt;br /&gt;  File dir = new File(dirPath);&lt;br /&gt;&lt;br /&gt;  if(!dir.exists()){&lt;br /&gt;   boolean success = dir.mkdir();&lt;br /&gt;   if (!success) {&lt;br /&gt;    System.out.println("Directory creation failed");&lt;br /&gt;    return null;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;  return dirPath;&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Another thing we could do is have the method create a sub-directory based on the file name without extension.&lt;br /&gt;&lt;pre&gt;public static String getDirectoryFromFileName(String fname) {&lt;br /&gt;&lt;br /&gt;  String parent =  (new File(fname).getParent());&lt;br /&gt;  &lt;span class="comment"&gt;//extract a file name without extension from the path&lt;/span&gt;&lt;br /&gt;  String name = getFileName(fname);&lt;br /&gt;  String dirPath = parent+"\\" + name;&lt;br /&gt;&lt;br /&gt;  File dir = new File(dirPath);&lt;br /&gt;&lt;br /&gt;  if(!dir.exists()){&lt;br /&gt;   boolean success = dir.mkdir();&lt;br /&gt;   if (!success) {&lt;br /&gt;    System.out.println("Directory creation failed");&lt;br /&gt;    return null;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;  return dirPath;&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-4698424170892651436?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/4698424170892651436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/create-sub-directory-from-file-name-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4698424170892651436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4698424170892651436'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/create-sub-directory-from-file-name-in.html' title='Create Sub-Directory From File Name in Java'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-1653384674242553245</id><published>2011-05-13T13:18:00.001-07:00</published><updated>2011-05-13T13:18:51.456-07:00</updated><title type='text'>Remove Duplicates in Java</title><content type='html'>&lt;p&gt;&lt;b&gt;Description:&lt;/b&gt;&lt;br&gt; You have an ArrayList with duplicates, and you need to remove them &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;  &lt;blockquote&gt; &lt;ul&gt; &lt;li&gt;Create a HashSet with the ArrayList as the constructor argument:&lt;br /&gt;  &lt;br&gt;&lt;pre&gt;HashSet hashSet = new HashSet(myArrayList);&lt;/pre&gt; &lt;li&gt;If the order is important, use a LinkedHashSet:&lt;br /&gt; &lt;br&gt;&lt;pre&gt;LinkedHashSet  linkedHashSet = new LinkedHashSet(myArrayList);&lt;/pre&gt; &lt;li&gt; Use the following method to remove duplcates:&lt;br /&gt;&lt;pre&gt;static ArrayList deDupKeepingFirst(ArrayList withDups,&lt;br /&gt;  Comparator comparator,boolean presorted) {&lt;br /&gt; if (!presorted) {&lt;br /&gt;  Collections.sort(withDups, comparator);&lt;br /&gt; }&lt;br /&gt; int size = withDups.size();&lt;br /&gt;&lt;br /&gt; ArrayList result = new ArrayList(size);&lt;br /&gt; if (size &lt;= 1) {&lt;br /&gt;  if (size == 1) {&lt;br /&gt;   result.add(withDups.get(0));&lt;br /&gt;  }&lt;br /&gt;  return result;&lt;br /&gt; }&lt;br /&gt; Object prev = withDups.get(0);&lt;br /&gt; result.add(prev);&lt;br /&gt;&lt;br /&gt; for (int i = 1; i &lt; size; i++) {&lt;br /&gt;  Object o = withDups.get(i);&lt;br /&gt;  if (comparator.compare(o, prev) != 0) {&lt;br /&gt;   result.add(o);&lt;br /&gt;   prev = o;&lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;   System.out.println(o.toString());&lt;br /&gt; }&lt;br /&gt; return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private static class StringComp implements Comparator&lt;br /&gt;{&lt;br /&gt; public int compare(Object o1, Object o2)&lt;br /&gt; {&lt;br /&gt;  return o1.toString().compareToIgnoreCase((o2).toString());&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;/ul&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-1653384674242553245?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/1653384674242553245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/remove-duplicates-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/1653384674242553245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/1653384674242553245'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/remove-duplicates-in-java.html' title='Remove Duplicates in Java'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-6309719088514239433</id><published>2011-05-13T13:15:00.000-07:00</published><updated>2011-05-13T13:15:13.211-07:00</updated><title type='text'>Sorting ArrayLists in Java</title><content type='html'>&lt;b&gt;Description:&lt;/b&gt;&lt;br /&gt;You have an ArrayList of objects that you need to be sorted by their&lt;br /&gt;integer member variables &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Solution: &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Let's say you have a Record class with the following members: int id, int weight;&lt;br /&gt;&lt;pre&gt;class Record {&lt;br /&gt; public Record(int i, int w){&lt;br /&gt;  this.id =i;&lt;br /&gt;  this.weight = w;&lt;br /&gt; }&lt;br /&gt; int id;&lt;br /&gt; int weight;&lt;br /&gt;&lt;br /&gt; public int getId() {&lt;br /&gt;  return id;&lt;br /&gt; }&lt;br /&gt; public int getWeight() {&lt;br /&gt;  return weight;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You have an &lt;b&gt;ArrayList &lt;/b&gt;of objects of the Record class that need to be sorted by weight. To make it possible, the Record class needs to implement the &lt;b&gt;&lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Comparable.html"&gt;Comparable &lt;/a&gt;&lt;/b&gt;interface which mandates the use of the &lt;b&gt;compareTo&lt;/b&gt; method with the following signature:&lt;br /&gt;&lt;pre&gt;&lt;/pre&gt;public int compareTo(Object o)&lt;br /&gt;&lt;br /&gt;That means we need to add the following code to the Record class:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;public int compareTo(Object o) {&lt;br /&gt; int weight = ((Record) o).getWeight();&lt;br /&gt; return weight - this.weight;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;We use &lt;code&gt;weight - this.weight&lt;/code&gt; for descending order and&lt;br /&gt;&lt;code&gt;this.weight - weight &lt;/code&gt;for ascending order.&lt;br /&gt;&lt;br /&gt;Once we have the proper method in the Record class, all we need to do is use the &lt;b&gt;sort&lt;/b&gt; method&lt;br /&gt;of the &lt;b&gt;&lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html"&gt;Collections&lt;/a&gt;&lt;/b&gt; class.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;Collections.sort (myArrayList);&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-6309719088514239433?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/6309719088514239433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/sorting-arraylists-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/6309719088514239433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/6309719088514239433'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2011/05/sorting-arraylists-in-java.html' title='Sorting ArrayLists in Java'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-6738109078749432383</id><published>2010-05-25T15:24:00.000-07:00</published><updated>2011-05-13T13:31:28.779-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Calendar'/><title type='text'>Determine the Next Month in Java</title><content type='html'>&lt;p&gt;First, get an instance of the Calendar class:&lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;Calendar cal = GregorianCalendar.getInstance();&lt;br /&gt;&lt;/pre&gt;Declare a format to be used:&lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;SimpleDateFormat df = new SimpleDateFormat("MMM yyyy");&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Set the Calendar's current time to today's Date:&lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;cal.setTime(new Date());&lt;/pre&gt;&lt;p&gt;Add a month to the Calendar's date:&lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;cal.add(Calendar.MONTH, 1);&lt;/pre&gt;&lt;p&gt;Format the new date into a string:&lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;String nextMonth = df.format(cal.getTime());&lt;/pre&gt;&lt;p&gt;The nextMonth String will contain the next month's value.&lt;br /&gt;&lt;p&gt;The following technique allows us to show 12 consecutive months:&lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;cal&lt;span style='color:#808030; '&gt;.&lt;/span&gt;setTime&lt;span style='color:#808030; '&gt;(&lt;/span&gt;new Date&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#800080; '&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;for&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;int&lt;/span&gt; i&lt;span style='color:#808030; '&gt;=&lt;/span&gt;&lt;span style='color:#008c00; '&gt;0&lt;/span&gt;&lt;span style='color:#800080; '&gt;;&lt;/span&gt; i&lt;span style='color:#808030; '&gt;&amp;lt;&lt;/span&gt;&lt;span style='color:#008c00; '&gt;12&lt;/span&gt;&lt;span style='color:#800080; '&gt;;&lt;/span&gt;i&lt;span style='color:#808030; '&gt;+&lt;/span&gt;&lt;span style='color:#808030; '&gt;+&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#800080; '&gt;{&lt;/span&gt;&lt;br /&gt;   cal&lt;span style='color:#808030; '&gt;.&lt;/span&gt;add&lt;span style='color:#808030; '&gt;(&lt;/span&gt;Calendar&lt;span style='color:#808030; '&gt;.&lt;/span&gt;MONTH&lt;span style='color:#808030; '&gt;,&lt;/span&gt; &lt;span style='color:#008c00; '&gt;1&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#800080; '&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span style='color:#603000; '&gt;String&lt;/span&gt; nextMonth &lt;span style='color:#808030; '&gt;=&lt;/span&gt; df&lt;span style='color:#808030; '&gt;.&lt;/span&gt;format&lt;span style='color:#808030; '&gt;(&lt;/span&gt;cal&lt;span style='color:#808030; '&gt;.&lt;/span&gt;getTime&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#800080; '&gt;;&lt;/span&gt;&lt;br /&gt;   System&lt;span style='color:#808030; '&gt;.&lt;/span&gt;out&lt;span style='color:#808030; '&gt;.&lt;/span&gt;println&lt;span style='color:#808030; '&gt;(&lt;/span&gt;nextMonth&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#800080; '&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style='color:#800080; '&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;The Calendar class has a lot of other methods to set its date. For example, you can set the year and month as follows:&lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;cal.set(Calendar.YEAR, 2010);&lt;br /&gt;cal.set(Calendar.MONTH, 05);&lt;br /&gt;&lt;/pre&gt;or&lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;cal.set(Calendar.MONTH, Calendar.JUNE);&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This code sets the Calendar date to June 2010.&lt;br /&gt;&lt;p&gt;You can also set the date using year, month, and day arguments.&lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;cal.set(2010, 05, 15);&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This code sets the Calendar date to June 15, 2010.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-6738109078749432383?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/6738109078749432383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/determine-next-month-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/6738109078749432383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/6738109078749432383'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/determine-next-month-in-java.html' title='Determine the Next Month in Java'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-6498405447458541226</id><published>2010-05-24T19:46:00.000-07:00</published><updated>2010-05-26T05:22:07.929-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hashtable'/><title type='text'>Enumerate All Keys of a Hashtable</title><content type='html'>&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: Consolas, "Courier New", Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;Set keys = myHashTable.keySet();&lt;br /&gt;Iterator iter = keys.iterator();&lt;br /&gt;&lt;span class="kwrd"&gt;while&lt;/span&gt; (iter.hasNext())&lt;br /&gt;{&lt;br /&gt;    Object key = iter.next();&lt;br /&gt;    System.&lt;span class="kwrd"&gt;out&lt;/span&gt;.println(&lt;span class="str"&gt;"key:"&lt;/span&gt;+ (String)key);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-6498405447458541226?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/6498405447458541226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/enumerate-all-keys-of-hashtable.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/6498405447458541226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/6498405447458541226'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/enumerate-all-keys-of-hashtable.html' title='Enumerate All Keys of a Hashtable'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-5352276704160426778</id><published>2010-05-24T19:42:00.000-07:00</published><updated>2010-05-26T05:22:18.043-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>A Simple Way to Find Data in XML Using dom4j</title><content type='html'>&lt;a href="http://www.dom4j.org/"&gt;dom4j &lt;/a&gt; is a small but  powerful package to parse XML documents. It has the advantage of having a very small footprint and being very easy to  use. The &lt;a href="http://www.dom4j.org/guide.html"&gt;dom4j website&lt;/a&gt; has a  lot of examples that show how to use it. &lt;br /&gt;If you have a simple xml file like the following one, I will show you  how to use dom4j to find data.&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{&amp;nbsp;&amp;nbsp;&amp;nbsp; font-size: small;&amp;nbsp;&amp;nbsp;&amp;nbsp; color: black;&amp;nbsp;&amp;nbsp;&amp;nbsp; font-family: Consolas, "Courier New", Courier, Monospace;&amp;nbsp;&amp;nbsp;&amp;nbsp; background-color: #ffffff;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {&amp;nbsp;&amp;nbsp;&amp;nbsp; background-color: #f4f4f4;&amp;nbsp;&amp;nbsp;&amp;nbsp; width: 100%;&amp;nbsp;&amp;nbsp;&amp;nbsp; margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;students&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;student&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Mike&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;course&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;JSP&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;course&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;student&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;student&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Janet&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;course&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;EJB&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;course&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;student&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;students&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;The file name is &lt;b&gt;students.xml&lt;/b&gt;. &lt;br /&gt;Suppose, you need to  find the course for a student named Mike. &lt;br /&gt;First, you need to parse a document:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; Document parse(String file) throws DocumentException {&lt;br /&gt;    SAXReader reader = &lt;span class="kwrd"&gt;new&lt;/span&gt; SAXReader();&lt;br /&gt;    Document document = reader.read(file);&lt;br /&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; document;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Document doc= parse(&lt;span class="str"&gt;"students.xml"&lt;/span&gt;);&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;Then, use the following statement: &lt;br /&gt;&lt;pre class="csharpcode"&gt;String course = doc.valueOf("//student[name='Mike']/course");  &lt;/pre&gt;This statement uses an XPath Engine library from &lt;a href="http://www.jaxen.org/"&gt;Jaxen&lt;/a&gt; which means you need to have it in your classpath. &lt;br /&gt;If you want to limit your library usage to dom4j proper  you'll  have to write your own method which may look like the following: &lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; String findStudentCourse(Document doc, String studentName) {&lt;br /&gt;    Element root = doc.getRootElement();&lt;br /&gt;    &lt;span class="kwrd"&gt;for&lt;/span&gt; (Iterator i = root.elementIterator(); i.hasNext();) {&lt;br /&gt;        Element el = (Element) i.next();&lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (el.elementText(&lt;span class="str"&gt;"name"&lt;/span&gt;).equals(studentName)) {&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; el.elementText(&lt;span class="str"&gt;"course"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;If you want to iterate through all the student elements and print the name-course combinations use the following example:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;Element root = document.getRootElement();&lt;br /&gt;&lt;span class="kwrd"&gt;for&lt;/span&gt; (Iterator i = root.elementIterator(); i.hasNext();) {&lt;br /&gt;    Element el = (Element) i.next();&lt;br /&gt;    System.&lt;span class="kwrd"&gt;out&lt;/span&gt;.println(&lt;span class="str"&gt;"Child Element Path :"&lt;/span&gt; + el.getPath());&lt;br /&gt;    System.&lt;span class="kwrd"&gt;out&lt;/span&gt;.println(&lt;span class="str"&gt;"    Name:"&lt;/span&gt; + el.elementText(&lt;span class="str"&gt;"name"&lt;/span&gt;));&lt;br /&gt;    System.&lt;span class="kwrd"&gt;out&lt;/span&gt;.println(&lt;span class="str"&gt;"    Course:"&lt;/span&gt; + el.elementText(&lt;span class="str"&gt;"course"&lt;/span&gt;));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-5352276704160426778?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/5352276704160426778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/simple-way-to-find-data-in-xml-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/5352276704160426778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/5352276704160426778'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/simple-way-to-find-data-in-xml-using.html' title='A Simple Way to Find Data in XML Using dom4j'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-9208961751444688433</id><published>2010-05-24T19:30:00.000-07:00</published><updated>2010-05-26T05:22:31.486-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Collection'/><title type='text'>Convert  Collection to Array</title><content type='html'>The following example converts an &lt;b&gt;ArrayList &lt;/b&gt;into an array of strings:&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: Consolas, "Courier New", Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;    ArrayList al = &lt;span class="kwrd"&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;    &lt;span class="rem"&gt;//Fill the array &lt;/span&gt;&lt;br /&gt;    ...........&lt;br /&gt;&lt;br /&gt;    String[] aStrings = (String[]) al.toArray(&lt;span class="kwrd"&gt;new&lt;/span&gt; String[0]);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-9208961751444688433?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/9208961751444688433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/convert-collection-to-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/9208961751444688433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/9208961751444688433'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/convert-collection-to-array.html' title='Convert  Collection to Array'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-4294529375950104778</id><published>2010-05-24T19:13:00.000-07:00</published><updated>2010-05-26T05:22:43.441-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='String'/><title type='text'>Find and Replace All Occurrencies of a String</title><content type='html'>&lt;b&gt;Description:&lt;/b&gt;&lt;br /&gt;You need to replace all occurencies of a  string in a text file&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Solution: (For Java 1.4 and higher) &lt;/b&gt; '&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: Consolas, "Courier New", Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; readReplace(String fname, String oldPattern, String replPattern){&lt;br /&gt;    String line;&lt;br /&gt;    StringBuffer sb = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuffer();&lt;br /&gt;    &lt;span class="kwrd"&gt;try&lt;/span&gt; {&lt;br /&gt;        FileInputStream fis = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInputStream(fname);&lt;br /&gt;        BufferedReader reader=&lt;span class="kwrd"&gt;new&lt;/span&gt; BufferedReader ( &lt;span class="kwrd"&gt;new&lt;/span&gt; InputStreamReader(fis));&lt;br /&gt;        &lt;span class="kwrd"&gt;while&lt;/span&gt;((line = reader.readLine()) != &lt;span class="kwrd"&gt;null&lt;/span&gt;) {&lt;br /&gt;            line = line.replaceAll(oldPattern, replPattern);&lt;br /&gt;            sb.append(line+&lt;span class="str"&gt;"\n"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;        reader.close();&lt;br /&gt;        BufferedWriter &lt;span class="kwrd"&gt;out&lt;/span&gt;=&lt;span class="kwrd"&gt;new&lt;/span&gt; BufferedWriter ( &lt;span class="kwrd"&gt;new&lt;/span&gt; FileWriter(fname));&lt;br /&gt;        &lt;span class="kwrd"&gt;out&lt;/span&gt;.write(sb.toString());&lt;br /&gt;        &lt;span class="kwrd"&gt;out&lt;/span&gt;.close();&lt;br /&gt;    }&lt;br /&gt;    &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Throwable e) {&lt;br /&gt;                System.err.println(&lt;span class="str"&gt;"*** exception ***"&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-4294529375950104778?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/4294529375950104778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/find-and-replace-all-occurrencies-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4294529375950104778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4294529375950104778'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/find-and-replace-all-occurrencies-of.html' title='Find and Replace All Occurrencies of a String'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4586519034017659067.post-4726790982235558348</id><published>2010-05-24T14:35:00.000-07:00</published><updated>2010-05-26T05:22:52.809-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Excel'/><title type='text'>Transfer data from Excel to Access through Java</title><content type='html'>This is sample code that shows how to use Java to transfer data from Excel  spreadsheets to Access. The basic idea is to create an ODBC data source for both Excel and  Access. Then use the JDBC API to retrieve records from the Excel ODBC source and insert them to Access.&lt;br /&gt;The Excel ODBC source is represented by  "jdbc:odbc:BulkMail", and the  Access ODBC source is represented by "jdbc:odbc:Whisky" in the code. &lt;br /&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: Consolas, "Courier New", Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;import java.sql.*;&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ExcelToAccess {&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; main (String[] args)&lt;br /&gt;{&lt;br /&gt;&lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;Class.forName (&lt;span class="str"&gt;"sun.jdbc.odbc.JdbcOdbcDriver"&lt;/span&gt;);&lt;br /&gt;String sourceURL = &lt;span class="str"&gt;"jdbc:odbc:BulkMail"&lt;/span&gt;;&lt;br /&gt;String sourceAccess = &lt;span class="str"&gt;"jdbc:odbc:Whisky"&lt;/span&gt;;&lt;br /&gt;Connection dbConnection = DriverManager.getConnection(sourceURL);&lt;br /&gt;Connection dbAccess = DriverManager.getConnection(sourceAccess);&lt;br /&gt;String comp;&lt;br /&gt;String fax;&lt;br /&gt;Statement st = dbConnection.createStatement();&lt;br /&gt;Statement stAccess = dbAccess.createStatement();&lt;br /&gt;ResultSet rs = st.executeQuery(&lt;span class="str"&gt;"Select LastName, FirstName, Company, FaxNumber from Customers"&lt;/span&gt;);&lt;br /&gt;&lt;span class="kwrd"&gt;while&lt;/span&gt; (rs.next()){&lt;br /&gt;    comp = rs.getString (&lt;span class="str"&gt;"Company"&lt;/span&gt;);&lt;br /&gt;    fax = rs.getString (&lt;span class="str"&gt;"FaxNumber"&lt;/span&gt;);&lt;br /&gt;    stAccess.executeUpdate(&lt;span class="str"&gt;"INSERT INTO Company (CompanyName, FaxNumber) VALUES('"&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;+ comp + &lt;span class="str"&gt;"','"&lt;/span&gt; + fax + &lt;span class="str"&gt;"')"&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;rs.close();&lt;br /&gt;dbConnection.close();&lt;br /&gt;dbConnection =&lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;br /&gt;dbAccess.close();&lt;br /&gt;dbAccess = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;catch&lt;/span&gt;(SQLException sqle)&lt;br /&gt;{ System.err.println(sqle); }&lt;br /&gt;&lt;span class="kwrd"&gt;catch&lt;/span&gt;(ClassNotFoundException cnfe)&lt;br /&gt;{ System.err.println(cnfe); }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4586519034017659067-4726790982235558348?l=java-code-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-code-snippets.blogspot.com/feeds/4726790982235558348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/transfer-data-from-excel-to-access.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4726790982235558348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4586519034017659067/posts/default/4726790982235558348'/><link rel='alternate' type='text/html' href='http://java-code-snippets.blogspot.com/2010/05/transfer-data-from-excel-to-access.html' title='Transfer data from Excel to Access through Java'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
