Label

Thứ Tư, 19 tháng 1, 2011

Integer.parseInt() and StringTokenizer


private int getSize(String sizeString , int defaultSize) {
try {
return(Integer.parseInt(sizeString));
} catch (NumberFormatException nfe) {
return(defaultSize);
}
}

private String makeList(String str){
String resultList = "
    \n";
    StringTokenizer List = new StringTokenizer(str, ",");
    while(List.hasMoreTokens()){
    resultList += "
  • " + List.nextToken() + "\n";
    }
    resultList += "
\n";
return(resultList);
}



getSize chuyen so format String -> integer
nakeList dung StringTokenizer, tuong tu voi Enumeration

Thứ Sáu, 14 tháng 1, 2011

Fixing the Eclipse PermGen Space (Out of Memory) Error When Using JDK 1.6.0_21

eclipse.ini

-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.0.v20100503
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256m
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-XX:MaxPermSize=256m

http://www.coreservlets.com/Apache-Tomcat-Tutorial/eclipse-jdk1.6.0_21-permgen-bug.html

ERROR:
http://www.eclipse.org/forums/index.php?t=msg&goto=542715&

Thứ Sáu, 7 tháng 1, 2011

Line break

		String lineSeparator = (String) java.security.AccessController.doPrivileged(new sun.security.action.GetPropertyAction("line.separator"));
System.out.print("Line break" + lineSeparator + "How?");

Thứ Năm, 6 tháng 1, 2011

range value of byte

		byte[] b = new byte[400];
int j = 0;
for (int i = -128; i < 128; i++){
b[j] = i;
System.out.println(j + " " + i);
j++;

}

Gia tri se lap lai mac du da toi 127, lap lai tu -128, cu tiep tuc nhu the', that. la....

vi tu 127, tang them 1 don vi se thanh -128. va vi the ma khong thoat khoi vog lap