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

Java½â»ó2 21ÎÒµÄÀàÊÇʲôII

ÏÂÃæµÄ³ÌÐòËùÒª×öµÄÊÂÇéÕýÊÇÇ°Ò»¸öÃÕÌâËù×öµÄÊÂÇ飬µ«ÊÇËüûÓмÙÉèб¸Ü·ûºÅ¾ÍÊÇ·Ö¸ôÎļþÃû×é³É²¿·ÖµÄ·ûºÅ¡£Ïà·´£¬¸Ã³ÌÐòʹÓõÄÊÇjava.io.File.separator£¬Ëü±»Ö¸¶¨ÎªÒ»¸ö¹«¹²µÄStringÓò£¬°üº¬ÁËƽ̨Ïà¹ØµÄÎļþÃû·Ö¸ô·û¡£ÄÇô£¬Õâ¸ö³ÌÐò»á´òÓ¡³öÆäÕýÈ·µÄ¡¢Æ½Ì¨Ïà¹ØµÄÀàÎļþÃûÂð£¿
package com.javapuzzlers;
import java.io.File;
public class MeToo {
public static void main(String[] args){
System.out.println(MeToo.class.getName().
replaceAll("\\.", File.separator) + ".class");
}
}
Õâ¸ö³ÌÐò¸ù¾Ýµ×²ãƽ̨µÄ²»Í¬»áÏÔʾÁ½ÖÖÐÐΪÖеÄÒ»ÖÖ¡£Èç¹ûÎļþ·Ö¸ô·ûÊÇб¸Ü£¬¾ÍÏñÔÚUNIXÉÏÒ»Ñù£¬ÄÇô¸Ã³ÌÐò½«´òÓ¡com/javapuzzlers/MeToo.class£¬ÕâÊÇÕýÈ·µÄ¡£µ«ÊÇ£¬Èç¹ûÎļþ·Ö¸ô·ûÊÇ·´Ð±¸Ü£¬¾ÍÏñÔÚWindowsÉÏÒ»Ñù£¬ÄÇô¸Ã³ÌÐò½«´òÓ¡ÏñÏÂÃæÕâÑùµÄÄÚÈÝ£º
Exception in thread "main"
java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.charAt(String.java:558)
at java.util.regex.Matcher.appendReplacement(Mather.
java:696)
at java.util.regex.Matcher.replaceAll(Mather.java:806)
at java.lang.String.replaceAll(String.java:2000)
at com.javapuzzlers.MeToo.main(MeToo.java:6)
¾¡¹ÜÕâÖÖÐÐΪÊÇƽ̨Ïà¹ØµÄ£¬µ«ÊÇËü²¢·Ç¾ÍÊÇÎÒÃÇËùÆÚ´ýµÄ¡£ÔÚWindowsÉϳöÁËʲô´íÄØ£¿
ÊÂʵ֤Ã÷£¬String.replaceAllµÄµÚ¶þ¸ö²ÎÊý²»ÊÇÒ»¸öÆÕͨµÄ×Ö·û´®£¬¶øÊÇÒ»¸öÌæ´ú×Ö·û´®£¨replacement string£©£¬¾ÍÏñÔÚjava.util.regex¹æ·¶ÖÐËù¶¨ÒåµÄÄÇÑù[Java-API]¡£ÔÚÌæ´ú×Ö·û´®ÖгöÏֵķ´Ð±¸Ü»á°Ñ½ôËæÆäºóµÄ×Ö·û½øÐÐתÒ壬´Ó¶øµ¼ÖÂÆä±»°´×ÖÃ溬Òå¶ø´¦ÀíÁË¡£
µ±ÄãÔÚWindowsÉÏÔËÐиóÌÐòʱ£¬Ìæ´ú×Ö·û´®Êǵ¥¶ÀµÄÒ»¸ö·´Ð±¸Ü£¬ËüÊÇÎÞЧµÄ¡£²»¿É·ñÈÏ£¬Å׳öµÄÒì³£Ó¦¸ÃÌṩ¸ü¶àһЩÓÐÓõÄÐÅÏ¢¡£
ÄÇôÄãÓ¦¸ÃÔõÑù½â¾ö´ËÎÊÌâÄØ£¿5.0°æ±¾ÌṩÁ˲»ÊÇÒ»¸ö¶øÊÇÁ½¸öеķ½·¨À´½â¾öËü¡£µÚÒ»¸ö·½·¨ÊÇjava.util.regex.Matcher.quoteReplacement£¬Ëü½«×Ö·û´®×ª»»³ÉÏàÓ¦µÄÌæ´ú×Ö·û´®¡£ÏÂÃæչʾÁËÈçºÎʹÓÃÕâ¸ö·½·¨À´¶©Õý¸Ã³ÌÐò£º
System.out.println(MeToo.class.getName().replaceAll("\\.",
Matcher.quoteReplacement(File.separator)) + ".class");
ÒýÈëµ½5.0°æ±¾Öеĵڶþ¸ö·½·¨ÌṩÁËÒ»¸ö¸üºÃµÄ½â¾ö·½°¸¡£¸Ã·½·¨¾ÍÊÇString.replace(CharSequence, CharSequ


Ïà¹ØÎĵµ£º

JavaÕýÔò±í´ïʽÏê½â


JavaÕýÔò±í´ïʽÏê½â
2005-10-08 10:01×÷ÕߣºÏÉÈËÕƹ¤×÷ÊÒ³ö´¦£ºKissJava.comÔðÈα༭£ºÍõÓñº­
Èç¹ûÄãÔø¾­ÓùýPerl»òÈκÎÆäËûÄÚ½¨ÕýÔò±í´ïʽ֧³ÖµÄÓïÑÔ£¬ÄãÒ»¶¨ÖªµÀÓÃÕýÔò±í´ïʽ´¦ÀíÎı¾ºÍÆ¥ÅäģʽÊǶàô¼òµ¥¡£Èç¹ûÄã²»ÊìϤÕâ¸öÊõÓÄÇô“ÕýÔò±í´ïʽ”£¨Regular Expression£©¾ÍÊÇÒ»¸ö×Ö·û¹¹³ÉµÄ´®£¬Ëü¶¨ÒåÁ ......

JavaµÚÒ»Ìì


Õýʽ¿ªÊ¼JavaÁË.
ÏÈÊÇÅäÖÃJava
java_home path classpath(1.5ÒÔÉÏ°æ±¾¿ÉÒÔ²»ÓÃÅäÖÃclasspathÁË)
²»¹ý±­¾ßµÄÊÇ.Ò»¿ªÊ¼Àí½â´íÁË.ÒÔΪclasspathµÄ".;"--µ±Ç°Ä¿Â¼ÊÇÖ¸javac X:\aa.javaµÄÄĸöX:Ŀ¼..È»ºójava aa¾Í²»ÓÃÖ¸¶¨ÁË..
ŪÁ˺þö¼²»ÊÇÕâÑùµÄ..»¹ÒÔΪÊÇwin 7µÄÔ­Òò..Orz
JavaÅäÖúÃÁË.¸ÃÑ¡Îı¾±à¼­Æ÷ÁË..
ͬѧ½Ð ......

javaÖо²Ì¬±äÁ¿ºÍ¾²Ì¬·½·¨·Ö±ðÓÐʲôÌص㣿

javaÖо²Ì¬±äÁ¿ºÍ¾²Ì¬·½·¨·Ö±ðÓÐʲôÌص㣿
ÐüÉÍ·Ö£º0 - ½â¾öʱ¼ä£º2006-4-10 10:28

ÌáÎÊÕߣº vv_clear - ¶þ¼¶
×î¼Ñ´ð°¸
ΪʲôÎÊÁËÁ½´Î£¿ÔÙÌùÉÏÁíһƪ
Thinking:JavaÖÐstaticÓ÷¨- -
Tag£º Thinking:JavaÖÐs
Ò»¡¢static
ÇëÏÈ¿´ÏÂÃæÕâ¶Î³ÌÐò£º
public class ......

JAVA+Swing +sql ·ÖÒ³´úÂë

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
impo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ