javaÖзÃÎÊmemcache
ÓÃspyºÍmemcached for javaÁ½ÖÖ·½Ê½¶Ômemcache½øÐвÙ×÷
Ò»¡¢spy
package com.test.memcache;
import java.net.InetSocketAddress;
import java.util.concurrent.Future;
import net.spy.memcached.MemcachedClient;
/**
* ±¾ÀàÓõİüÊÇmemcached-2.4.1.jar
* ÏÂÔØµØÖ·£º http://code.google.com/p/spymemcached/
*/
public class SpyTest {
public void putObject() {
try {
/* ½¨Á¢MemcachedClient ʵÀý£¬²¢Ö¸¶¨memcached·þÎñµÄIPµØÖ·ºÍ¶Ë¿ÚºÅ */
MemcachedClient mc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
Future<Boolean> b = null;
/* ½«keyÖµ£¬¹ýÆÚʱ¼ä(Ãë)ºÍÒª»º´æµÄ¶ÔÏósetµ½memcachedÖÐ */
b = mc.set("key1", 60, "hello1"); // Èç¹ûÒÔǰ´æÔÚ£¬Ôò»á×Ô¶¯¸²¸Ç
if (b.get().booleanValue() == true) {
mc.shutdown();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void getObject() {
try {
/* ½¨Á¢MemcachedClient ʵÀý£¬²¢Ö¸¶¨memcached·þÎñµÄIPµØÖ·ºÍ¶Ë¿ÚºÅ */
MemcachedClient mc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
/* °´ÕÕkeyÖµ´ÓmemcachedÖвéÕÒ»º´æ£¬²»´æÔÚÔò
Ïà¹ØÎĵµ£º
Ôڳɹ¦ÊµÏÖJavaµ÷ÓÃC++Ö®ºó£¬½ÓÏÂÀ´Ïëµ½ÄÜ·ñͨ¹ýJNAʵÏÖJavaµ÷ÓÃFortran£¬½ñÌìÊÔÑéÁËһϣ¬»¹ÊDZȽÏÈÝÒ׵ġ£
ÍøÉÏÓÐÒ»¸öJavaµ÷ÓÃF95µÄÀý×Ó£¬µ«ÊÇÎÒ¿¼ÂDz»½öҪʵÏÖF95µÄµ÷Ó㬻¹ÒªÊµÏÖF77µÄµ÷Óã¬ËùÒÔ·ÑÁËһЩÖÜÕÛ¡£
ÎÊÌâµÄ¹Ø¼üÔÚÓÚF77Ϊ¹ý³ÌÃû×Ô¶¯Ìí¼ÓÁËÒ»¸öβ²¿µÄÏ»®Ïߣ¬ËùÒÔsub1Õâ¸ö¹ý³Ì£¬µ½JavaÒ»¶Ë£¬¾Í±ä³ÉÁËsub1_£¬ ......
ÓÉÓÚÊÖÍ·ÓиöÏîÄ¿ÐèÒªÓõÄJavaµÄÊäÈëÊä³ö²Ù×÷£¬
¡¡¡¡ËùÒÔ£¬¿ÐÁ˼¸ÌìÊ飬¶ÔJavaµÄÁ÷¼¼ÊõÓÐЩÁ˽⣬²»¹ý£¬»¹ÊÇÓкܶ಻ÊǺÜÃ÷°×£¬ÏÂÃæÊÇÎÒ¿´ÊéÕûÀíµÄһЩ±Ê¼Ç£¬ÑϸñµÄ˵Ӧ¸Ã²»ÊÇÔ´´£¬ÎÒÌù³öÀ´Ö»ÊÇÏ£Íû¶Ô´ó¼ÒÓÐһЩ°ïÖú
¡¡¡¡
¡¡¡¡1¡¢JavaÓµÓÐÒ»¸öÍêÕûµÄÁ÷ÀàÐÍ£¬×ÜÊý³¬¹ý60£¬¶øËĸö³éÏóÀ๹³ÉÁËÕâЩÀàµÄ»ù´¡
¡¡¡¡
¡¡¡¡In ......
Ò»¸öÈí¼þÉè¼ÆµÄºÃ»µ£¬ÎÒÏëºÜ´ó³Ì¶ÈÉÏÈ¡¾öÓÚËüµÄÕûÌå¼Ü¹¹£¬¶øÕâ¸öÕûÌå¼Ü¹¹Æäʵ¾ÍÊÇÄã¶ÔÕû¸öºê¹ÛÉÌÒµÒµÎñµÄ³éÏó¿ò¼Ü£¬µ±´ú±íÒµÎñÂß¼µÄ¸ß²ã³éÏó²ã½á¹¹ ºÏÀíʱ£¬Äãµ×²ãµÄ¾ßÌåʵÏÖÐèÒª¿¼Âǵľͽö½öÊÇһЩËã·¨ºÍһЩ¾ßÌåµÄÒµÎñʵÏÖÁË¡£µ±ÄãÐèÒªÔÙ¿ª·¢ÁíÒ»¸öÏà½üµÄÏîĿʱ£¬ÄãÒÔǰµÄ³éÏó²ã˵²»¶¨»¹¿ÉÒÔÔÙ´ÎÀûÓÃ ÄØ£¬Ãæ¶Ô¶ÔÏóµÄÉè¼Æ ......
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
/**
* @author dengshaohua
*/
public class ReadPhone {
/**
* ¶ÁÈ¡Êý¾Ý
*/
public void ReadData(){
try {
FileReader read = new File ......
±¾ÎÄ´Óhttp://www.blogjava.net/breezedancer/archive/2007/07/19/131264.html×ªÔØ
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
//¶ÏµãÐø´ ......