Recent Notes

Displaying keyword search results 11 - 17
Created by Dr. Xi on February 24, 2010 21:13:05    Last update: February 24, 2010 21:19:54
This program demonstrates the use of the java.nio package to implement a single thread echo server. import; import
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 , with some minor bug fixes. Example usage: <taskdef name="mergeProperty" classname="ant.task.... Implementation: package ant.task.addon; import
Created by Dr. Xi on November 19, 2008 00:22:27    Last update: January 07, 2010 23:00:36
There is a open source project named [ini4j] for processing Windows .ini configuration files. However, I found it an overkill for my purposes. So here is my simple implementation of a .ini parser. It mimics the standard java.util.Properties class with enhancements to get and set properties by section name. There are only a few simple rules: Leading and trailing spaces are trimmed from section names, property names and property values. Section names are enclosed between [ and ] . Properties following a section header belong to that section Properties defined before the appearance of any section headers are considered global properties and should be set and get with no section names. You can use either equal sign ( = ) or colon ( : )...
Created by Dr. Xi on September 17, 2008 04:18:49    Last update: August 07, 2009 03:19:42
Simple enum: enum Suite { SPADE, HEART, DI... Enum with code and description: import java.util.*; enum Suite { SP...
Created by Dr. Xi on April 18, 2009 21:41:01    Last update: April 29, 2009 03:23:55
While Python is strongly typed and wouldn't allow you to concatenate string s with int s, it gladly compares strings to ints, with unexpected results: >>> '09' + 10 Traceback (most recent call last)... Use the int function to convert string to int and the str function to convert int to string: >>> int('10') 10 >>> str(10) '10' >>> ... To convert an array of strings: >>> map(lambda x: int(x), ['1', '2', '3']) [1, ...
Created by Dr. Xi on September 17, 2008 03:55:20    Last update: January 14, 2009 20:01:59
Java collections can only hold object references, so you have to box primitive values into the appropriate wrapper class (e.g., Integer for int ). When you take an Integer out of a collection, you have to unbox the object to primitive before you can do numerical calculations. The JDK 1.5 autoboxing feature makes this transparent to you. For example: Map<String, Integer> m = new HashMap<String, I...
Created by Dr. Xi on September 25, 2008 02:56:24    Last update: September 25, 2008 03:00:10
When you use a TreeMap , the entries in the Map is sorted by the keys. This following code outputs the elements of the map sorted by value. import java.util.*; @SuppressWarnings("... The output is: key: e, value: be key: g, value: by key:...
Previous  1 2 Next