Displaying keyword search results 1 - 6
Created by Dr. Xi on June 22, 2011 07:33:45 Last update: June 22, 2011 11:57:54
Demo code for CSV parsing with OpenCSV . Java code:
import java.io.*; import au.com.bytecode.opencs...Test with a simple CSV file:
psmith01,CLASS2B,Peter Smith 1,YEAR2,1,N,ADVANCED,...The parser worked correctly:
Line 1 has 11 values: |psmith01| |CLASS2B|...Test with a more complicated CSV file:
"psmith01 abc", "CLASS2B " , " Peter...Result:
Line 1 has 4 values: |psmith01 abc| |CLASS...The parser: Escaped quote and backslash correctly Ignored spaces before the quotation mark - sometimes (see below) Counted spaces after the right quotation mark till the comma as content, including the right quotation mark (bug). Ignored improperly quoted item - silently (third line) Indeed, the OpenCSV parser has a problem with spaces: Input:
"Smith, Jack", "210-345-8888" "Smith, J...Result:
Line 1 has 2 values: | Smith, Jack| |210-3......
Created by Dr. Xi on October 16, 2008 20:45:40 Last update: March 28, 2011 20:23:22
Java's built-in classes are way too complex/flexible for a simple protocol like HTTP. This is a wrapper to simplify HTTP GET and POST.
import java.io.*; import java.net.*; imp...A simple test:
import java.io.*; import java.util.*; ...
Created by Dr. Xi on January 08, 2010 03:53:37 Last update: January 08, 2010 03:54:56
This is an Ant custom task to merge Properties files I lifted from http://marc.info/?l=ant-user&m=106442688632164&w=2 , with some minor bug fixes. Example usage:
<taskdef name="mergeProperty" classname="ant.task....Implementation:
package ant.task.addon; import java.io.Buff...
Created by Dr. Xi on August 21, 2008 22:35:24 Last update: October 16, 2008 02:27:59
import java.net.*; import java.io.*; pub...An example for POSTing from Java is available from here: http://www.javaworld.com/javaworld/javatips/jw-javatip34.html
Created by Dr. Xi on September 04, 2008 18:18:07 Last update: September 04, 2008 18:18:07
If the argument to getResourceAsStream is a directory, the stream content returns a list of files under that directory. The following code returns the list of files under the first directory on CLASSPATH (not the current directory):
import java.io.*; public class TestGetResou...
Created by Dr. Xi on December 12, 2007 20:30:01 Last update: December 12, 2007 20:32:23
This is a script to tail a log file through the web browser. It uses AJAX, apache web server, mod_python, UNIX utilities tail (requires the --lines switch) and wc . The log file may reside on the web server or any other host accessible from the web server through SSH. Although it's written in python, it should be easy to port to other languages such as Perl. Apache httpd.conf :
LoadModule python_module modules/mod_python.so ...Python script:
import time, os from os.path import basename ...