Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

base64 ±à½âÂëµÄ Java ʵÏÖ

/**
* Base64Util for Java
* cheungmine
* 2009-11-8
*/
public class Base64Util {
/**
* @param args
*/
public static void main(String[] args)
{
// Ô´×Ö½ÚÊý×é
int cb = 0;
System.out.print("Ô´×Ö½ÚÊý×é: ");

byte in[] = new byte[100];
in[cb++]='1';
in[cb++]='2';
in[cb++]='3';
in[cb++]='4';
in[cb++]='5';

System.out.write(in, 0, cb);

// ¼ÆËã±àÂëÐèÒªµÄÊä³ö×ֽڳߴç
int cbOut = encodeString( in, cb, null, 0);

// ΪÊä³ö·ÖÅäÊý×é
byte out[] = new byte[cbOut];

// ¿ªÊ¼±àÂë
encodeString( in, cb, out, 0);

// Êä³ö±àÂëÄÚÈÝ
System.out.print("\n±àÂëºóÄÚÈÝ: ");
System.out.write(out, 0, cbOut);

// ¼ÆËã½âÂëÐèÒªµÄ×Ö½Ú
int cbDec = decodeString(out, cbOut, null);

// ·ÖÅä½âÂëÊý×é
byte dec[] = new byte[cbDec];

// ¿ªÊ¼½âÂë
decodeString(out, cbOut, dec);

// Êä³ö½âÂë½á¹û, Õâ¸ö½á¹ûºÍÊä³öÓ¦¸ÃÒ»ÖÂ
System.out.print("\n½âÂëµÄ½á¹û: ");
System.out.write(dec, 0, cbDec);
}

/**
* Translation Table as described in RFC1113
*/
static String cb64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/**
* Translation Table to decode (created by author)
*/
static String cd64="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
/**
* encodeBlock
*
* encode 3 8-bit binary bytes (in) as 4 '6-bit' characters (out)
*/
static void encodeBlock( byte in[], byte out[], int len )
{
out[0] = (byte) cb64.charAt( in[0] >> 2 );
out[1] = (byte) cb64.charAt( ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) );
out[2] = (byte) (len > 1 ? cb64.charAt( ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ) : '=');
out[3] = (byte) (len > 2 ? cb64.charAt( in[2] & 0x3f ) : '=');
}

/**
* decodeBlock
*
* decode 4 '6-bit' characters into 3 8-bit binary bytes
*/


Ïà¹ØÎĵµ£º

javaÈëÃÅ

 Javaѧϰ´ÓÈëÃŵ½¾«Í¨ 
Ò»¡¢ JDK (Java Development Kit) 
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......

Java ÀíÂÛºÍʵ¼ù:·ºÐÍ11ÔÂ06ÈÕ[תÌù]

     Java ÀíÂÛºÍʵ¼ù: Á˽ⷺÐÍ Ê¶±ðºÍ±ÜÃâѧϰʹÓ÷ºÐ͹ý³ÌÖеÄÏÝÚå
 
      JDK 5.0 ÖÐÔö¼ÓµÄ·ºÐÍÀàÐÍ£¬ÊÇ Java ÓïÑÔÖÐÀàÐÍ°²È«µÄÒ»´ÎÖØÒª¸Ä½ø¡£µ«ÊÇ£¬¶ÔÓÚ³õ´ÎʹÓ÷ºÐÍÀàÐ͵ÄÓû§À´Ëµ£¬·ºÐ͵ÄijЩ·½Ãæ¿´ÆðÀ´¿ÉÄܲ»ÈÝÒ×Ã÷°×£¬ÉõÖÁ·Ç³£Ææ¹Ö¡£ÔÚ±¾ÔµÄ"Java Àí ......

JavaÖÐCalendarºÍDateµÄһЩʹÓÃÓ÷¨¼¼ÇÉ

1. Èç¹ûÒѾ­ÖªµÀij¸öµØµãµÄʱÇø£¬Ä꣬Ô£¬ÈÕ£¬Ê±£¬·Ö£¬Ã룬ϣÍûµÃµ½×ª»»ºóµÄ±¾ÏµÍ³Ê±¼ä£¬¿ÉÒÔ²ÉÓÃÈçϵķ½·¨£º
·½·¨£º¼ÙÉèʱÇøÊÇGMT+08:00,£¬ÄêÊÇ2009Ä꣬ÔÂÊÇ11Ô£¬ÈÕÊÇ7ÈÕ£¬Ê±ÊÇ10ʱ£¬·ÖÊÇ50·Ö£¬ÃëÊÇ30¡£
public class Time {
 
 public static void main(String[] args) {
  TimeZone tz = Tim ......

javaºËÐĽ̳̱ʼÇ

1.privateÐÞÊη½·¨²»Äܱ»ÍⲿÀàµ÷Óá£
2.finalÐÞÊεĶÔÏó¹¹½¨ºó²»Äܱ»Ð޸ġ£
À©Õ¹:
finalÀ಻Äܱ»¼Ì³Ð£¬Ã»ÓÐ×ÓÀ࣬finalÀàÖеķ½·¨Ä¬ÈÏÊÇfinal¡£
final²»Äܱ»×ÓÀàµÄ·½·¨¸²¸Ç£¬µ«¿ÉÒÔ±»¼Ì³Ð¡£
final³ÉÔ±±äÁ¿±íʾ³£Á¿£¬Ö»Äܱ»¸³ÖµÒ»´Î£¬¸³ÖµºóÖµ²»Ôٸı䡣
final²»ÄÜÓÃÓÚÐÞÊι¹Ôì·½·¨¡£
finalº¯Êý²ÎÊýÎÞ·¨±»¸Ä±ä¡£
¸¸ ......

Java¶ÁȡͼƬÎļþµÄ¿í¶ÈºÍ¸ß¶È

InputStream is = new FileInputStream(filename);//ͨ¹ýÎļþÃû³Æ¶ÁÈ¡
»ò
InputStream is =new ByteArrayInputStream(byte[] a);//ͨ¹ýÎļþµÄ×Ö½ÚÊý×é¶ÁÈ¡
BufferedImage buff = ImageIO.read(is);
buff.getWidth();¡¡//µÃµ½Í¼Æ¬µÄ¿í¶È
buff.getHeight();  //µÃµ½Í¼Æ¬µÄ¸ß¶È
is.close(); //¹Ø±ÕStream ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ