俊星的BLOG

          #

          Angela's Ashes 天使的孩子

          今天偶然在一片博客上看到了《Angela's Ashes》的介紹,又在YOUKU上發(fā)現(xiàn)了一段原聲音樂(lè),帶點(diǎn)憂傷,很合我胃口。
          不過(guò),在網(wǎng)上沒(méi)有找到能免費(fèi)看的,那就上淘寶買(mǎi)一張吧。

          posted @ 2009-05-29 16:43 俊星 閱讀(105) | 評(píng)論 (0)編輯 收藏

          MYSQL Access denied 問(wèn)題的解決

          今天嘗試通過(guò)JDBC連接局域網(wǎng)的另一臺(tái)機(jī)器,拋出了如下異常:
          com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'wiki'
              at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:
          936)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
          2985)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
          885)
              at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:
          3421)
              at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:
          1247)
              at com.mysql.jdbc.Connection.createNewIO(Connection.java:
          2775)
              at com.mysql.jdbc.Connection.<init>(Connection.java:
          1555)
              at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:
          285)
              at java.sql.DriverManager.getConnection(DriverManager.java:
          525)
              at java.sql.DriverManager.getConnection(DriverManager.java:
          171)
              at test.tool.WikiStat.getConn(WikiStat.java:
          18)
              at test.tool.WikiStat.main(WikiStat.java:
          23)

          具體的解決方法為,授予相關(guān)用權(quán)限,如:
          mysql> grant select on *.* to 'root'@'%' identified by 'password';
          Query OK, 0 rows affected (0.00 sec)

          mysql> flush privileges
          ;
          Query OK, 0 rows affected (0.00 sec)

          mysql> exit
          Bye

          命令“grant select on *.* to 'root'@'%' identified by 'password'”所作的事情其實(shí)就是在“mysql.user”表中添加了一行記錄,
          因此如果需要?jiǎng)h除某個(gè)授權(quán),直接找到user表執(zhí)行刪除就OK了。

          posted @ 2009-05-27 19:54 俊星 閱讀(2347) | 評(píng)論 (0)編輯 收藏

          JAVA小工具之文件查找

          需要在一堆文件夾中查找一個(gè)exe文件,實(shí)在無(wú)法忍受windows的查找功能,自己寫(xiě)了一個(gè)簡(jiǎn)單的JAVA類(lèi),實(shí)現(xiàn)了查找:
          package test.tool;

          import java.io.BufferedReader;
          import java.io.File;
          import java.io.FileReader;
          import java.io.IOException;
          import java.util.regex.Matcher;
          import java.util.regex.Pattern;

          /**
           * 
           * 
          @author kinkding
           * @history 2009-5-26
           
          */

          public class FindFile {
              
          private String fileName = "";
              
          private String dir = "";
              
          private Matcher m = null;
              
          private int count = 0;

              
          public FindFile() throws IOException {
                  String f 
          = FindFile.class.getResource("findfile.properties").getFile();
                  BufferedReader read 
          = new BufferedReader(new FileReader(f));
                  dir 
          = read.readLine().trim();
                  fileName 
          = read.readLine().trim();
                  Pattern p 
          = Pattern.compile(fileName);
                  m 
          = p.matcher("");
              }


              
          public void find() {
                  File root 
          = new File(dir);
                  
          for (File f : root.listFiles()) {
                      
          if (f.isDirectory()) {
                          dir 
          = f.getAbsolutePath();
                          find();
                      }
           else {
                          m.reset(f.getName());
                          
          if (m.find()) {
                              count
          ++;
                              System.out.println(f.getAbsolutePath());
                          }

                      }

                  }

              }


              
          public static void main(String[] args) {
                  
          try {
                      FindFile ff 
          = new FindFile();
                      ff.find();
                      System.out.println(
          "\n共找到文件數(shù)目:" + ff.count);
                  }
           catch (IOException e) {
                      e.printStackTrace();
                  }

              }

          }


          findfile.properties:
          F:\download
          vod.
          *.exe

          運(yùn)行效果如下:
          F:\download\firefox\vodplayer.exe
          F:\download\ie\vodplayer.exe

          共找到文件數(shù)目:
          2

          相關(guān)說(shuō)明:
          之所以加載配置文件時(shí)不采用java.util.Properties類(lèi),是因?yàn)榕渲玫穆窂?#8220;F:\download”通過(guò)getProperty方法取得時(shí)候,去掉了文件分割符,所以直接就采用流的方式讀取,第一行默認(rèn)目錄,第二行默認(rèn)文件名,并且對(duì)文件名采用正則匹配。

          posted @ 2009-05-26 22:54 俊星 閱讀(850) | 評(píng)論 (0)編輯 收藏

          IE修復(fù)的相關(guān)命令

          IE修復(fù)的相關(guān)命令:
          "%ProgramFiles%\Internet Explorer\iexplore.exe" /rereg

          regsvr32 Shdocvw.dll
          regsvr32 Oleaut32.dll
          regsvr32 Actxprxy.dll
          regsvr32 Mshtml.dll
          regsvr32 Urlmon.dll
          regsvr32 browseui.dll

          regsvr32 hhctrl.ocx

          posted @ 2009-05-26 20:22 俊星 閱讀(114) | 評(píng)論 (0)編輯 收藏

          JAVA字符編碼

          測(cè)試代碼:
              public static void main(String[] args) {
                  Locale.setDefault(Locale.US);
                  String str 
          = "中G中";
                  String codes[] 
          = "iso8859-1""utf-8""utf-16""unicode""gbk""gb2312" };
                  
          try {
                      System.out.println(str);
                      System.out.println(
          "default code:" + System.getProperty("file.encoding"));
                      
          for (String s : codes) {
                          System.out.println(s 
          + "" + toHex(str.getBytes(s)));
                      }

                  }
           catch (UnsupportedEncodingException e) {
                      e.printStackTrace();
                  }

              }


              
          private static String toHex(byte[] buffer) {
                  StringBuffer sb 
          = new StringBuffer(buffer.length * 3);

                  
          for (int i = 0; i < buffer.length; i++{
                      sb.append(Character.forDigit((buffer[i] 
          & 0xf0>> 416));
                      sb.append(Character.forDigit(buffer[i] 
          & 0x0f16));
                      sb.append(
          " ");
                  }


                  
          return sb.toString();
              }

          輸出如下:
          中G中
          default code:GBK
          iso8859-
          1: 3f 47 3f 
          utf-
          8: e4 b8 ad 47 e4 b8 ad 
          utf-
          16: fe ff 4e 2d 00 47 4e 2d 
          unicode: ff fe 2d 4e 
          47 00 2d 4e 
          gbk: d6 d0 
          47 d6 d0 
          gb2312: d6 d0 
          47 d6 d0 

          相關(guān)說(shuō)明:
          1、通過(guò)System.getProperty("file.encoding")獲取到當(dāng)前JVM的默認(rèn)字符編碼方式,如GBK
          2、iso8859-1則是應(yīng)用于英文和歐洲其他語(yǔ)言的單字節(jié)編碼字符集,“3f”其實(shí)對(duì)應(yīng)就是“?”。
          3、utf-8則是unicode編碼的一種轉(zhuǎn)換方式(Unicode Transformation Format),兼容于ASCII編碼,如對(duì)于中文則使用3個(gè)字節(jié)來(lái)存儲(chǔ),對(duì)于英文使用一個(gè)字節(jié)存儲(chǔ)。
          4、utf-16是unicode編碼的另一種轉(zhuǎn)換方式,每個(gè)直接都采用2個(gè)字節(jié)來(lái)存儲(chǔ),所以不兼容于ASCII;
                其中“fe ff”是Byte Order Mark(BOM)表示采用的編碼方式為utf-16。
          5、此處的unicode輸出和utf-16本質(zhì)相同,只不過(guò)大小尾序的問(wèn)題導(dǎo)致單個(gè)字節(jié)輸出順序相反;
                其中對(duì)于windows和linux平臺(tái)的utf-16默認(rèn)采用小尾序(LE little Endion),mac平臺(tái)采用大尾。
          6、gbk和gb2312是中文字符集,對(duì)于每個(gè)字符均采用2個(gè)字節(jié)存儲(chǔ),其中g(shù)bk兼容gb2312并且還可表示繁體。

          關(guān)于存儲(chǔ)字節(jié)的計(jì)算,假設(shè)現(xiàn)在有N個(gè)中文和M個(gè)英文字符,則如下的計(jì)算方式(編碼方式:字節(jié)數(shù)):
          GBK:2*N+M
          UTF-8:3*N+M
          UTF-16:2*(N+M+1)
          ISO8859-1:N+M

          posted @ 2009-05-26 00:12 俊星 閱讀(224) | 評(píng)論 (0)編輯 收藏

          僅列出標(biāo)題
          共10頁(yè): 上一頁(yè) 1 2 3 4 5 6 7 8 9 下一頁(yè) Last 
          主站蜘蛛池模板: 高清| 荥阳市| 崇文区| 九台市| 繁峙县| 克什克腾旗| 星子县| 高唐县| 新平| 南丰县| 城口县| 靖远县| 郧西县| 江永县| 衡南县| 西昌市| 阿勒泰市| 西藏| 新兴县| 扬州市| 喀什市| 钟山县| 丰镇市| 昌都县| 峡江县| 五寨县| 凭祥市| 怀宁县| 延边| 汝州市| 刚察县| 岑溪市| 博湖县| 博客| 建瓯市| 孝感市| 遵义市| 中江县| 壤塘县| 湖南省| 吉隆县|