锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 鍦ㄧ綉涓婃壘浜嗗緢涔呮墠鎵懼埌developerWorks涓婄殑涓涓В鍐蟲柟妗堬細 鍦ㄥ懡浠ゆ彁紺虹閲屽垏鎹㈠埌鐩綍“C:\Program Files\IBM\SDP70\jdk\jre\bin”錛岃繍琛?#8220;java.exe -Xshareclasses:destroyAll” 榪欐牱灝辮兘姝e父鍚姩RAD浜嗭紒 鍘熷洜鎻忚堪濡備笅錛?/p>
錛堟憳褰曡嚜http://www-1.ibm.com/support/docview.wss?uid=swg21281393錛屽茍閫氳繃Google Translate杞瘧錛岃瘧鏂囧凡浣滀慨鏀癸級 ××××××××××××××××××××××××××××××××××××× 闂錛堟憳瑕侊級 瑙e喅闂 ××××××××××××××××××××××××××××××××××××××
姝よ鏄庤В閲婂浣曡В鍐抽敊璇?#8220;JVM鐨勭粓姝€傞鍑轟唬鐮? 1”銆?br />
璧峰洜
RAD鑷甫鐨処BM JVM浣跨敤浜嗕竴涓珮閫熺紦瀛樺弬鏁版潵鎻愰珮鎬ц兘銆傝屽洜涓篔VM鐨勫穿婧冿紝姣斿钃濆睆錛屾垨鏂數錛岄兘鍙兘閫犳垚Java楂橀熺紦瀛樿鎹熷潖銆?鑰孞VM浼氭嫆緇濊繛鎺ュ埌涓涓崯鍧忕殑楂橀熺紦瀛樸?/p>
瑕佽В鍐寵繖涓棶棰橈紝浣跨敤“-Xshareclasses:destroyAll”鐨凧ava閫夐」灝嗛攢姣佹墍鏈夌殑鍏變韓綰х紦瀛樸傝繖鏄竴縐嶅疄鐢ㄥ伐鍏烽夐」錛屾墍浠ヤ笉浼氬惎鍔↗VM 銆傚鏋滄偍鎯寵榪欎箞鍋氾紝鍙浠庡懡浠ゆ彁紺虹浣跨敤鍙傛暟“-Xshareclasses:destroyAll”鏉ヨ繍琛孯AD浣跨敤鐨刯ava銆?/p>
]]>
浠庝竴澶у爢涔辯爜涓壘鍑哄彲浠ョ悊瑙g殑淇℃伅錛堝瓧姣嶏級
Java瑙e喅鏂規錛?br />
public static void main(String[] args) throws Exception {
URL url = new URL("http://www.pythonchallenge.com"
+ "/pc/def/ocr.html");
BufferedReader reader = new BufferedReader(new
InputStreamReader(url.openStream()));
StringBuffer sb = new StringBuffer();
int i = reader.read();
while(i != -1)
{
if((i >= (int)'A' && i <= (int)'Z')
|| (i >= (int)'a' && i <= (int)'z'))
{
sb.append((char)i);
}
i = reader.read();
}
reader.close();
String source = sb.toString();
//欏甸潰婧愮爜涓渶鍚庝竴涓崟璇嶆槸below
System.out.println(
source.substring(source.indexOf("below") + 5)
);
}
}
闄凱ython鍜孲hell錛?br />
Python:
<copy and paste>
"""
>>> import string
>>> for i in text:
if i in string.ascii_letters:
print i,
Shell:
$ curl http://www.pythonchallenge.com/pc/def/ocr.html | grep -o [a-z]
]]>
Java瑙e喅鏂規錛?
2 public static void main(String[] args) {
3 String a = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq "
+ "ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb "
+ "gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq "
+ "qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. "
+ "lmu ynnjw ml rfc spj.";
4 char[] ac = a.toCharArray();
5 int zi = (int)'z';
6 int ai = (int)'a';
7 for(int index=0; index<ac.length; index++)
8 {
9 int aci = (int)ac[index];
10 if(aci >= ai && aci <= zi)
11 {
12 int aci2 = (int)ac[index] + 2;
13
14 System.out.print((char)((aci2>zi)?(aci2%(zi+1)+ai):aci2));
15 }
16 else
17 {
18 System.out.print((char)aci);
19 }
20 }
21 }
22 }
闄勪笂Python鍜孲hell瑙e喅鏂規錛?br />
Python:
2 >>> text = """g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr
3 amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q
4 ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb.
5 lmu ynnjw ml rfc spj."""
6 >>> table = string.maketrans(
7 string.ascii_lowercase,
8 string.ascii_lowercase[2:]+string.ascii_lowercase[:2])
Shell:
]]>
]]>
]]>
]]>
]]>
鏂規硶錛氬惈涓澶у彛姘達紝灝忓彛鍒嗗嬈″悶涓嬶紝鐩磋嚦涓嶆墦鍡濄?錛堜竴鑸袱澶у彛姘撮噺灝卞彲浠ユ悶瀹氾級
PS: 浠g爜瀹炵幇錛?br>
2銆乯sp:usebean 鐨刢lass灞炴у簲璇ユ槸綾葷殑鍏ㄥ悕錛堝寘鎷寘鍚嶏級銆傚湪鍓嶉潰<%@ import>涓璱mport鐨勫寘錛屽湪tag閲屼笉璧蜂綔鐢紝鍙jsp閲岄潰鐨刯ava浠g爜鏈夌敤錛屾墍浠ag閲岃浣跨敤綾葷殑鍏ㄥ悕
3銆乸ost鏃跺鏋滆〃鍗曢噷鏈変腑鏂囷紝浼氬嚭鐜頒腑鏂囦貢鐮侊紝鍦╯ervlet閲岃皟鐢╮equest.getParameter涔嬪墠鎵цrequest.setCharacterEncoding("gb2312");灝卞彲浠ユ紜瘑鍒拰鏄劇ず涓枃浜嗭紱
濡傛灉鏄痷rl涓敤涓枃鍙傛暟錛屽someaction.jsp?q=涓枃闂錛屽垯瑕佸姞涓涓猣ilter鏉etEncoding錛屽洜涓簆ost鍜実et浼犻佸弬鏁扮殑澶勭悊鏂瑰紡涓嶄竴鏍楓倁rl涓寘鍚腑鏂囧弬鏁扮殑璁劇疆鍙傝冿細http://www.itet.cn/0512456328001529/JSP/0691214511318687.html
鍚庢潵鎴戝紑濮嬩嬌鐢?strong>PreparedStatement錛屽湪SQL閲屼嬌鐢ㄢ滐紵鈥濇爣璁板弬鏁幫紝鐒跺悗鐢╯etXXX鏂規硶緇欏弬鏁拌祴鍊箋傚綋鏃跺彧鐭ラ亾榪欐牱鐢ㄦ槸鍥犱負鏈?strong>setDate錛宻etTimeStamp榪欎簺鐢ㄢ?鈥濊繛鎺ヤ笉鑳界洿鎺ュ祵鍏ョ殑鍊箋?br />
鎰熻PreparedStatement鍦?strong>鎬ц兘鏂歸潰搴旇涔熻兘蹇偣錛屽彲鑳紻BMS浼氶噸鐢紝浣嗕笉鏄庡簳灞傚師鐞嗐?br />
榪欐銆婃暟鎹簱瀹炵幇銆嬭紼嬬粓浜庤鎴戝紕鎳備簡錛?strong>姣忎釜SQL璇彞閮借閫氳繃 璇硶鍒嗘瀽 -> 鐢熸垚閫昏緫鏌ヨ璁″垝 -> 閫昏緫浼樺寲 -> 鐗╃悊浼樺寲 絳夋楠ょ敓鎴愬叿浣撶殑鎵ц璁″垝錛岀敤PreparedStatement灝卞彲浠ョ敓鎴愪竴涓墽琛岃鍒掞紝浠ュ悗鍙槸鍙傛暟鏀瑰彉錛堢浉褰撲簬鎵ц璁″垝鐨?strong>鎵ц鐜鏀瑰彉錛夛紝鍓嶉潰鐨勫洓涓楠や篃浼?strong>鐪佺暐錛屼粠鑰屾彁楂樹簡鏁堢巼銆?br />
濡傛灉涓涓猄QL璇彞瑕佽鍙嶅澶氭鎵ц錛屾垨澶氱敤鎴峰悓鏃舵搷浣滐紝鍒欏簲閫夌敤PreparedStatement錛?/p>
鏈鍚庝綔鑰呬互Struts涓轟緥錛屼粙緇嶄簡鍑犵閫夋嫨Ajax鐨勫満鏅細
1 鐜版湁鐨凷truts搴旂敤紼嬪簭瑕佷嬌鐢ˋjax錛岃浣跨敤AjaxAnywhere
2 寤虹珛鏂扮殑搴旂敤紼嬪簭鍑嗗浣跨敤Ajax錛屽弬鑰傾ppfuse錛屽畠闆嗘垚浜咲WR鐨凙jax
3 涓湡鐩爣錛?浣跨敤涓縐嶆敮鎸丄jax鐨凧SF鐨勫疄鐜幫紝MyFaces鎴栬匰truts Shale
鍘熸枃鍦板潃錛?A >http://blog.csdn.net/danny_xcz/archive/2006/03/03/614302.aspx
else if(queueSize() == 0) /* queueSize()宸茬粡琚悓姝?*/
{
break;
}
URLToDownload nextURL;
synchronized(queue)
{
nextURL = queue.getNextInQueue();
downloadsInProgress++;
}
synchronized(urlsDownloading)
{
urlsDownloading.add(nextURL);
}
int newDepth = nextURL.getDepth() + 1; **********************
synchronized(queue)
{
nextURL = queue.getNextInQueue();
if(nextURL == null)
{
continue;
}
downloadsInProgress++;
}
鐢ㄦ埛鍙瀹?#8220;娣卞害鎼滅儲”錛氭瘡鎼滃埌涓涓猽rl灝辨斁鍦╨ist鐨勬渶鍓嶉潰
涔熷彲騫垮害
鏈変簺緗戦〉閾炬帴瑕佺壒孌婂鐞嗭細
url = textReplace("?", URLEncoder.encode("?"), url);
url = textReplace("&", URLEncoder.encode("&"), url);
private String textReplace(String find, String replace, String input)
{
int startPos = 0;
while(true)
{
int textPos = input.indexOf(find, startPos);
if(textPos < 0)
{
break;
}
input = input.substring(0, textPos) + replace + input.substring(textPos + find.length());
startPos = textPos + replace.length();
}
return input;
}
璇誨彇璧勬簮浠g爜錛?/p>
BufferedInputStream remoteBIS = new BufferedInputStream(conn.getInputStream());
ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
byte[] buf = new byte[1024];
int bytesRead = 0;
while(bytesRead >= 0)
{
baos.write(buf, 0, bytesRead);
bytesRead = remoteBIS.read(buf);
}
byte[] content = baos.toByteArray();
File f = new File(fileName);
f.getParentFile().mkdirs();
FileOutputStream out = new FileOutputStream(fileName);
out.write(content);
out.flush();
out.close();
/**
* Set of URLs downloaded or scheduled, so we don't download a
* URL more than once.
* Thread safety: To access the set, first synchronize on it.
*/
private Set urlsDownloadedOrScheduled;
private final static Category _logClass = Category.getInstance(TextSpider.class);
/*
鏄劇ず淇℃伅: 2005-05-01 11:40:44,250 [main] INFO? TextSpider.java:105 - Starting Spider...
*/
_logClass.info("Starting Spider...");
Class.forName("weblech.util.Log4j");
friendcode.
Java by default restricts the friends of a class to those classes that are in the same package. If there is a functionality that you want share just among classes in the same package, use package-private modifier in definition of a constructor, a field or a method and then it will remain accessible only to friends
.
Sometimes however it is more useful to extend the set of friends to a wider range of classes - for example one wants to define a pure API package and put the implementation into separate one. In such cases following trick can be found useful. Imagine there is a class item:
public final class api.Item { /** Friend only constructor */ Item(int value) { this.value = value; } /** API method(s) */ public int getValue() { return value; } /** Friend only method */ final void addListener(Listener l) { // some impl } }that is part of the API, but cannot be instanitated nor listened on outside of the friend classes (but these classes are not only in api package). Then one can define an
Accessor
in the non-API package: public abstract class impl.Accessor { public static Accessor DEFAULT; static { // invokes static initializer of Item.class // that will assign value to the DEFAULT field above Class c = api.Item.class; try { Class.forName(c.getName(), true, c.getClassLoader()); } catch (ClassNotFoundException ex) { assert false : ex; } assert DEFAULT != null : "The DEFAULT field must be initialized"; } /** Accessor to constructor */ public abstract Item newItem(int value); /** Accessor to listener */ public abstract void addListener(Item item, Listener l); }with abstract methods to access all
friendfunctionality of the
Item
class and with a static field to get the accessor's instance. The main trick is to implement the Accessor
by a (non-public) class in the api
package: final class api.AccessorImpl extends impl.Accessor { public Item newItem(int value) { return new Item(value); } public void addListener(Item item, Listener l) { return item.addListener(l); } }and register it as the default instance first time somebody touches
api.Item
by adding a static initializer to the Item
class: public final class Item { static { impl.Accessor.DEFAULT = new api.AccessorImpl(); } // the rest of the Item class as shown above }Then the friend code can use the accessor to invoke the hidden functionality from any package:
api.Item item = impl.Accessor.DEFAULT.newItem(10); impl.Accessor.DEFAULT.addListener(item, this);
posted Friday, 30 December 2005