Notes by Dr. Xi

Displaying keyword search results 1 - 10
Created by Dr. Xi on March 14, 2012 14:23:14    Last update: March 14, 2012 14:23:14
If forgotPasswordForm.error is a String and not null, you cannot test the error condition with: <!-- This does not work! --> <c:if test="${forg... You have to use "not empty": <c:if test="${not empty forgotPasswordForm.error}"...
Created by Dr. Xi on February 13, 2012 16:03:58    Last update: February 13, 2012 16:05:19
Microsoft provides free downloadable Windows images to support IE browser compatibility testing, just google Internet Explorer Application Compatibility VPC Image . These VMs run on Microsoft's Windows Virtual PC . According to MS: You can technically have a base image which never expires although you will never be able to permanently save any changes on these images for longer than 90 days.
Created by Dr. Xi on February 13, 2012 15:56:20    Last update: February 13, 2012 15:56:20
IE9 has pretty good developer tools support - similar to that of Firebug, though not as good (under the Tools icon pick F12 Developer Tools , or hit F12 directly.). It also allows you to test compatibility with older browsers like IE8: Bring up Developer Tools with F12. pick IE8 in Browser Mode and IE8 standards in Document Mode .
Created by Dr. Xi on November 11, 2011 13:59:46    Last update: November 11, 2011 13:59:46
This is an example to replace a Java string with case insensitive match. Code: public class ReplaceTest { public static vo... Output: Done TEST tEst tESt Test Test TEST tEst tESt Te...
Created by Dr. Xi on November 11, 2011 10:05:22    Last update: November 11, 2011 10:12:01
This is an HTML image tag filter using Java regex. It takes a string, finds the img tags, replaces the src attribute with one provided by the filter, then adds a class name to the class attribute. import java.util.regex.*; import java.io.*; ... Test file: <div id="HTML snippet"> <img src="img/big/txt-m...
Created by Dr. Xi on July 27, 2011 08:55:34    Last update: July 27, 2011 08:55:34
It is OK to remove elements from a list with Iterator , but you get UnsupportedOperationException if the list is created with Arrays.asList : import java.util.*; public class IteratorRe... Prints: ArrayList test: ================ List size: ...
Created by Dr. Xi on July 15, 2011 09:25:15    Last update: July 15, 2011 09:25:15
Some methods to search for a substring within a string: To know that a substring indeed exists within a string: boolean found = wholeString.contains(substring); To find where the substring is contained: int index = wholeString.indexOf(substring); If the substring is regex: boolean match = wholeString.matches(".*" + substri... Case insensitive match: convert both whole string and substring to lowercase, then compare. Or, use case insensitive flag for regex. Test code: import java.util.regex.*; public class Stri...
Created by Dr. Xi on July 14, 2011 07:54:32    Last update: July 14, 2011 07:54:32
This is how to split a string using java.util.StringTokenizer : StringTokenizer tok = new StringTokenizer("this \... But don't do it ! According to JavaDoc : StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead. Using String.split , the equivalent code is: String[] tokens = "this \tis\n a\t test".split("\... Also note that the following yield different results: String[] tokens1 = "this \tis\n a\t test".split("...
Created by Dr. Xi on July 13, 2011 16:18:05    Last update: July 13, 2011 16:18:05
The goal is to read a file like this: for (String line: textFileReader) { // do s... This is the code: import java.io.*; import java.util.Iterator; ...
Created by Dr. Xi on June 22, 2011 15:15:15    Last update: June 22, 2011 15:15:15
There's no such thing as an immutable byte array in Java. What we are trying to achieve here is to protect the byte array inside the object from which it is being returned. We want to caller to have the contents of the byte array, but not be able to change the contents inside the object. The trick is to return a copy instead of the internal reference: public class ReturnByteArray { public stati...
Previous  1 2 3 4 5 6 7 8 9 Next