RSS feed [root] /string /weblog /java



title search:


Thu Feb 16 00:04:35 HKT 2017


(google search) (amazon search)
download zip of files only

Thu Feb 16 00:05:43 HKT 2017 From /weblog/java/string


Introduction to a library which support faster regular expression processing:[..]ite/archive/2006/03/a_faster_java_r.html[..]-expression-library-benchmarks-2015.html

Regex helper -

(google search) (amazon search)

Wed Jul 23 09:57:03 HKT 2014 From /weblog/java/string


Better sorting should do 2 things:
1) case insensitive
2) aware of numbers in the file names. So File2 comes after File1 (obviously) but before File10[..]ingcomparator_sorting_strings_for_people


Switch comparison -

(google search) (amazon search)

Mon Dec 02 11:47:12 HKT 2013 From /weblog/java/string


A common issue of Windows environment and the workaround -

Strange String issues in JVM languages, don't trust all string operations all the time![..]/posts/strangestringissuesinjvmlanguages

(google search) (amazon search)

Fri Nov 22 17:04:49 HKT 2013 From /weblog/java/string


Discussion of how to do string alignment -[..]va-implementation-of-optimal-string.html

(google search) (amazon search)

Tue Nov 19 17:19:59 HKT 2013 From /weblog/java/string


String.intern() is designed for constant strings, it's implemented in C/C++ in the hotspot core code, and it has a fixed-size hashmap of around 20K entries and if more than this number of strings are interned, the performance degrades linearly since there are hash collisions and the code has to search down linked lists.

String.intern in Java 7 and 8 -[..]-intern-java-6-7-8-multithreaded-access/

(google search) (amazon search)

Tue Feb 07 18:56:48 HKT 2006 From /weblog/java/string


Nice and simple toString():

public String toString() {

return MyClass.class.getSimpleName()

+ new LinkedHashMap() {{

put("foo", foo);

put("bar", bar);

put("tee", tee);



Results in:

MyClass[foo: fooValue, bar: barValue, tee: teeValue]

(google search) (amazon search)

Tue Nov 08 18:35:42 HKT 2005 From /weblog/java/string

string length

Surprisingly, String length more complicate than we excepted. A char is not necessarily a complete character, so if you need to know the character length, you need to use codePointCount method

int charLen = myString.length();
int characterLen = myString.codePointCount(0, charLen);

However, if you use UTF-8 encoding, string.length() will work as expected.

More detail see:

(google search) (amazon search)