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

java ´úÂëÉú³ÉÊý×ÖÖ¤Êé

http://liuleijsjx.javaeye.com/blog/422343
±¾È˸ÕдµÄѧϰÐĵà ϣÍûÄÜÓÐËù°ïÖú
/**
*´úÂëʵÀý ͨ¹ý·´±àÒë²é¿´keytoolµÄjava code»ñµÃµÄÊý×ÖÖ¤ÊéµÄÄÚ²¿Éú³É·½·¨
*ÍƼöʹÓÃjdk1.5
**/
1¡£Ê×ÏÈÉú³Éselfcert
CertAndKeyGen cak = new CertAndKeyGen("RSA","MD5WithRSA",null);
//²ÎÊý·Ö±ðΪ ¹«Ô¿Ëã·¨ Ç©ÃûËã·¨ providername£¨ÒòΪ²»ÖªµÀÈ·ÇÐµÄ Ö»ºÃʹÓÃnull ¼ÈʹÓÃĬÈϵÄprovider£©
cak.generate(1024);
//Éú³ÉÒ»¶Ôkey ²ÎÊýΪkeyµÄ³¤¶È ¶ÔÓÚrsa²»ÄÜСÓÚ512
X500Name subject = new X500Name("CN=simic,o=shanghai");
//subject name
X509Certificate certificate = cak.getSelfCertificate(subject,10);
// ºóÒ»¸ölongÐͲÎÊý´ú±í´ÓÏÖÔÚ¿ªÊ¼µÄÓÐЧÆÚ µ¥Î»ÎªÃ루Èç¹û²»Ïë´ÓÏÖÔÚ¿ªÊ¼Ëã ¿ÉÒÔÔÚºóÃæ¸ÄÕâ¸öÓò£©
BASE64Encoder base64
= new BASE64Encoder();
FileOutputStream fos = new FileOutputStream(new File("d:\\test.crt"));
base64.encodeBuffer(certificate.getEncoded(), fos);
//Éú³ÉcertÎļþ base64¼ÓÃÜ µ±È»Ò²¿ÉÒÔ²»¼ÓÃÜ
2¡£Éú³É·Ç×ÔÇ©µÄcert
Ê×ÏÈ°´ÕÕ1×ßÒ»±éÉú³ÉÒ»¸ö×ÔÇ©Ö¤Êé
byte certbytes[] = certificate.getEncoded();
X509CertImpl x509certimpl = new X509CertImpl(certbytes);
X509CertInfo x509certinfo = (X509CertInfo)x509certimpl.get("x509.info");
X500Name issuer = new X500Name("CN=fatal,o=shanghai");
x509certinfo.set("issuer.dname",issuer);
//ÉèÖÃissuerÓò
Date bdate = new Date();
Date edate = new Date();
edate.setTime(bdate.getTime() + validity * 1000L * 24L * 60L * 60L);
//validityΪÓÐЧʱ¼ä³¤¶È µ¥Î»ÎªÃë
CertificateValidity certificatevalidity = new CertificateValidity(bdate,
edate);
x509certinfo.set("validity", certificatevalidity);
//ÉèÖÃÓÐЧÆÚÓò£¨°üº¬¿ªÊ¼Ê±¼äºÍµ½ÆÚʱ¼ä£©ÓòÃûµÈͬÓëx509certinfo.VALIDITY
x509certinfo.set("serialNumber", new
CertificateSerialNumber((int)(date.getTime() / 1000L)));
//ÉèÖÃÐòÁкÅÓò
CertificateVersion cv = new CertificateVersion(CertificateVersion.V3);
x509certinfo.set(X509CertInfo.VERSION,cv);
//ÉèÖð汾ºÅ Ö»ÓÐv1 ,v2,v3Õ⼸¸öºÏ·¨Öµ
/**
*ÒÔÉÏÊÇÖ¤ÊéµÄ»ù±¾ÐÅÏ¢ Èç¹ûÒªÌí¼ÓÓû§À©Õ


Ïà¹ØÎĵµ£º

java±àÂë2

String str = "ÖÐ";
 
 
  String str1 = new String(str.getBytes("gbk"), "ISO8859-1");
  String str2 = new String(str1.getBytes("ISO8859-1"), "gbk");
  System.out.println(str2);  //Êä³ö"ÖÐ" ......

JavaʵÏÖÀûÓÃËÑË÷ÒýÇæÊÕ¼¯ÍøÖ·µÄ³ÌÐò

¡¡¡¡ÔõôÈóÌÐòÀûÓÃËÑË÷ÒýÇæÀ´ËѼ¯ÍøÖ·£¬ÕâÓÐʲôÓÃ?ºÜÓÐÓÃ!ÍøÉ϶¯éüÓÐÈ˽ÐÂôÍøÖ·Êý¾Ý¿â£¬Èç·¢²¼Èí¼þÍøÖ·¡¢ÓʼþµØÖ·¡¢ÂÛ̳ÍøÖ·¡¢ÐÐÒµÍøÖ·£¬ÕâЩÍøÖ·ÊÇÔõôÀ´µÄÄØ?²»¿ÉÄÜÊÇÈËÊÖ¹¤ÊÕ¼¯¶øÀ´µÄ£¬¶¼ÊÇÈóÌÐòÀûÓÃËÑË÷ÒýÇæÈ¡µ½µÄ£¬Èç¹ûÄúÐèҪijÀàÍøÖ·ÐÅÏ¢Êý¾Ý£¬¾Í¸ú³É¶¼ÀÊÎÖ½ÌÓýÀ´Ò»ÆðÑо¿Ò»Ï£¬·Ç³£¼òµ¥¡£
¡¡¡¡±¾ÎIJÉÓÃJavaÓïÑÔÐ ......

java³ÌÐòʵÏÖutf 8ת±¾µØ»¯±àÂë

package script;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
public class Change {
 public static void main(String[] args) throws Exception {
  Change c = new Change();
  c.utf8toLocaleCode();
&n ......

java¶ÁÎļþ

import java.io.*;
public class FileReaderSample {
  public static void main(String args[]) throws IOException
  {
    // ½¨Á¢¿ÉÈÝÄÉ1024¸ö×Ö·ûµÄÊý×é
    char data[]=new char[1024];
    // ½¨Á¢¶ÔÏófr
    FileReader fr= ......

java log add function

#dd_traces.pl (C) Marko Kivij?rvi 2006
# Dummy checks
die "Specify an input file!\n" if $ARGV[0] eq "";
die "File not found!\n" unless -e $ARGV[0];
die "Incorrect file extension for a C/C++ file!\n"
    if ( $ARGV[0] !~ /(.*)\.(java)$/ );
# Constants
my $IMPORT_LOG_PACKAG = "\n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ