Äêµ×ÊÕ²ØϵÁÐ Java Web¹¤¾ßSessionTick
package org.lambdasoft.web.support;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.lambdasoft.web.Enviroment;
public class SessionSupport {
private SessionSupport() {}
/**
* »ñÈ¡µ±Ç°Óû§Session
*
* @return httpSession
*/
public final static HttpSession getSession() {
return ServletActionContext.getRequest().getSession();
}
@SuppressWarnings("unchecked")
public final static void removeAllSession(HttpSession session) {
if(session == null)
return;
Enumeration names = session.getAttributeNames();
if(names == null)
return;
List<String> sessionNamesList = new ArrayList<String>();
while (names.hasMoreElements())
sessionNamesList.add((String)names.nextElement());
for (String sessionName : sessionNamesList) {
session.removeAttribute(sessionName);
}
}
/**
* Ìí¼Ó»òÕ߸üÐÂSessionƱ¾ÝÐÅÏ¢
*
* @param sessionTick
*/
public final static void updateSessionTick(SessionTick<TickInterface> sessionTick) {
getSession().removeAttribute(Enviroment.getEnv().getEnv("WEB_SESSION_KEY"));
getSession().setAttribute(Enviroment.getEnv().getEnv("WEB_SESSION_KEY"), sessionTick);
}
/**
* °ÑÓû§Æ±¾Ý¼ÓÈëµ½Session
* @param account
*/
public final static void addTickToSession(TickInterface account) {
SessionTick<TickInterface> tick = new SessionTick<TickInterface>();
tick.setAccount(account);
updateSessionTick(tick);
}
}
/*
* SessionTick.java
* Copyright (C) 2009 <JustinLei@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
*
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
First
Parsing an XML Document
To read an XML document, you need a DocumentBuilder object, which you get from a DocumentBuilderFactory, like this:DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
You can now read a docu ......
JavaÖУ¬Jniµ÷ÓÃDLLÎļþÊÔÑé
ËùÓÐÎļþ¾ùÔÚE:\·¾¶Ï¡£
°²×°jdk1.6.0_07
°²×°ÁËVC++6.0
µÚÒ»²½£¬
HelloWorld.java
µÚ¶þ²½£¬
E:\>javac HelloWorld.java
µÃµ½
HelloWorld.class
µÚÈý²½£¬
E:\>javah HelloWorld
µÃµ½
HelloWorld.h
µÚËIJ½£¬
±àдһ¸öCÎļþ
HelloWorldImp.c
µÚÎå²½£¬
ʹÓÃcl±àÒ ......
1. ×Ö·û´®ÓÐÕûÐ͵ÄÏ໥ת»»
¡¡¡¡Java´úÂë
¡¡¡¡String a = String.valueOf(2); //integer to numeric string
¡¡¡¡int i = Integer.parseInt(a); //numeric string to an int
¡¡¡¡2. ÏòÎļþĩβÌí¼ÓÄÚÈÝ
¡¡¡¡Java´úÂë
¡¡¡¡BufferedWriter out = null;
¡¡¡¡try {
¡¡¡¡out = new BufferedWriter(new FileWr ......