??xml version="1.0" encoding="utf-8" standalone="yes"?> 在网上找?jin)很久才扑ֈdeveloperWorks上的一个解x案:(x) 在命令提C符里切换到目录“C:\Program Files\IBM\SDP70\jdk\jre\bin”Q运?#8220;java.exe -Xshareclasses:destroyAll” q样p正常启动RAD?jin)?/strong> 原因描述如下Q?/p>
Q摘录自http://www-1.ibm.com/support/docview.wss?uid=swg21281393Qƈ通过Google Translate转译Q译文已作修改)(j) ××××××××××××××××××××××××××××××××××××× 问题Q摘要)(j) 解决问题 ××××××××××××××××××××××××××××××××××××××
此说明解释如何解决错?#8220;JVM的终止。退Z? 1”?br />
起因
RAD自带的IBM JVM使用?jin)一个高速缓存参数来提高性能。而因为JVM的崩溃,比如蓝屏Q或断电(sh)Q都可能造成Java高速缓存被损坏?而JVM?x)拒l连接到一个损坏的高速缓存?/p>
要解册个问题,使用“-Xshareclasses:destroyAll”的Java选项销毁所有的׃nU缓存。这是一U实用工具选项Q所以不?x)启动JVM 。如果?zhn)惌q么做,只要从命令提C符使用参数“-Xshareclasses:destroyAll”来运行RAD使用的java?/p>
]]>
从一大堆q中找出可以理解的信息Q字母)(j)
Java解决Ҏ(gu)Q?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)
);
}
}
附Python和ShellQ?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解决Ҏ(gu)Q?
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和Shell解决Ҏ(gu)Q?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:
]]>
]]>
]]>
]]>
]]>
Ҏ(gu)Q含一大口_(d)口分多ơ吞下,直至不打嗝?Q一般两大口水量可以搞定)(j)
PS: 代码实现Q?br>
2、jsp:usebean 的class属性应该是cȝ全名Q包括包名)(j)。在前面<%@ import>中import的包Q在tag里不起作用,只对jsp里面的java代码有用Q所以tag里要使用cȝ全名
3、post时如果表单里有中文,?x)出C文ؕ码,在servlet里调用request.getParameter之前执行request.setCharacterEncoding("gb2312");可以正识别和昄中文?jin)?br />
如果是url中用中文参数Q如someaction.jsp?q=中文问题Q则要加一个filter来setEncodingQ因为post和get传送参数的处理方式不一栗url中包含中文参数的讄参考:(x)http://www.itet.cn/0512456328001529/JSP/0691214511318687.html
后来我开始?strong>PreparedStatementQ在SQL里用“?”标记参敎ͼ然后用setXXXҎ(gu)l参数赋倹{当时只知道q样用是因ؓ(f)?strong>setDateQsetTimeStampq些用?”连接不能直接嵌入的倹{?br />
感觉PreparedStatement?strong>性能斚w应该也能快点Q可能DBMS?x)重用,但不明底层原理?br />
q次《数据库实现》课E终于让我弄懂了(jin)Q?strong>每个SQL语句都要通过 语法分析 -> 生成逻辑查询计划 -> 逻辑优化 -> 物理优化 {步骤生成具体的执行计划Q用PreparedStatement可以生成一个执行计划,以后只是参数改变Q相当于执行计划?strong>执行环境改变Q,前面的四个步骤也?strong>省略Q从而提高了(jin)效率?br />
如果一个SQL语句要被反复多次执行Q或多用户同时操作,则应选用PreparedStatementQ?/p>
最后作者以StrutsZQ介l了(jin)几种选择Ajax的场景:(x)
1 现有的Struts应用E序要用AjaxQ请使用AjaxAnywhere
2 建立新的应用E序准备使用AjaxQ参考AppfuseQ它集成?jin)DWR的Ajax
3 中期目标Q?使用一U支持Ajax的JSF的实玎ͼMyFaces或者Struts Shale
原文地址Q?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;深度搜烦(ch)”Q每搜到一个url放在list的最前面
也可q度
有些|页链接要特D处理:(x)
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;
}
d资源代码Q?/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