Time of Update: 2018-07-19
compareTo方法是比較兩個字串的詞典順序 也就是在字典中的順序,比如“abcd”在“acdb”前面 另外你應該先把字串轉變成int,然後再比較 可以用下面的方法比較兩個整數 public int max(int m,int n) { if(m>n) return m; else if(n>m) return n; else return
Time of Update: 2018-07-19
package com.test; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.tools.zip.ZipEntry; import
Time of Update: 2018-07-19
部落格轉自:http://blog.csdn.net/amosryan/article/details/6568783 功能目錄: 將輸入資料流轉換成位元組流 將檔案讀取為一個字串 以指定編碼格式將輸入資料流按行置入一個List<String> 以GBK格式將輸入資料流按行置入一個List<String>
Time of Update: 2018-07-19
1) 檢查當前環境中java&jdk的安裝情況 $ rpm -qa|grep jdk $ rpm -qa|grep java 2) 將上述2條命令執行後產生的列表中的項全部卸載
Time of Update: 2018-07-19
/** * 將產生的xml和附件打包成.tb檔案 * zipFileStorePath="D:\\testzip\\test.zip" * needToZipFilePath="D:\\testzip\\test" * */ public String zipAllFileToTb(String zipFileStorePath, String
Time of Update: 2018-07-19
Java基礎加強 - 註解 一.註解的定義 定義: 註解(Annotation)是一種標記性的介面,註解是Java的一個新的類型(與介面很相似),它與類(Class)、介面(interface)、枚舉(enum)是在同一個層次,註解相當於一種標記,在程式中加了註解就等於為程式打上了某種標記,沒加,則等於沒有某種標記。我們可以定義註解、聲明註解、獲得註解,並且根據獲得的註解做相應的處理,許多架構都大量應用了註解。
Time of Update: 2018-07-19
package Utils.Sort; /** *插入排序,要求待排序的數組必須實現Comparable介面 */ public class InsertSort implements SortStrategy { /** *利用插入排序演算法對obj進行排序
Time of Update: 2018-07-19
package Utils.Sort; /** *歸併排序,要求待排序的數組必須實現Comparable介面 */ public class MergeSort implements SortStrategy { private Comparable[] bridge; /**
Time of Update: 2018-07-19
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.servlet.ServletException; import
Time of Update: 2018-07-19
現在貼出部分核心代碼,在最後提供全部代碼下載連結。有感興趣的朋友,可以點選連結下載原始碼 二維碼,是一種採用黑白相間的平面幾何圖形通過相應的編碼演算法來記錄文字、圖片、網址等資訊的條碼圖片。 如下圖 一、Java 所需jar包:QRCode.jar http://vdisk.weibo.com/ QRCode類:二維碼操作核心類 package app.Code; import java.awt.Color; import
Time of Update: 2018-07-19
3.少用new初始化一個執行個體: 盡量少用 new 來初始化一個類的執行個體,當一個對象是用 new 進行初始化時,其建構函式鏈的所有建構函式都被調用 到,所以 new 操作符是很消耗系統資源的, new 一個對象耗時往往是局部變數賦值耗時的上千倍。同時,當產生對象 後,系統還要花時間進行記憶體回收和處理。 當 new 建立對象不可避免時,注意避免多次的使用 new
Time of Update: 2018-07-19
import java.io.File; public class DeleteFileUtil { /** * 刪除單個檔案 * @param sPath 被刪除檔案的檔案名稱
Time of Update: 2018-07-19
package Utils.Sort; /** *希爾排序,要求待排序的數組必須實現Comparable介面 */ public class ShellSort implements SortStrategy { private int[]
Time of Update: 2018-07-19
package Utils.Sort; /** *快速排序,要求待排序的數組必須實現Comparable介面 */ public class QuickSort implements SortStrategy { private static final int CUTOFF = 3; &
Time of Update: 2018-07-19
package Utils.Sort; /** *@author Tony Deng *利用選擇排序法對數組排序,數組中元素必須實現了Comparable介面。 */ public class ChooseSort implements SortStrategy {
Time of Update: 2018-07-19
java不解壓直接讀取.zip壓縮檔該樣本的,關於下面示範的項目源代下載地址如下: 原始碼下載地址 package com.sd.test.readzip;import java.io.BufferedInputStream;import java.io.BufferedReader;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import
Time of Update: 2018-07-19
package iotools.tomchaozhou.cuhk; import java.util.*; import java.io.*; // Displays directory listing. args[0] indicate which kind of file pattern to match. public class DirList { /** * @param args * The file pattern that need to be matched. */
Time of Update: 2018-07-19
1.File oldf = new File(oldFileName); File newf =null; if (oldf != null) { newf = new File(newFileName); oldf.renameTo(newf); }
Time of Update: 2018-07-19
private class MyFilenameFilter implements FilenameFilter {private Pattern p;public MyFilenameFilter(String regex) {p = Pattern.compile(regex);}public boolean accept(File file, String name) {return p.matcher(name).matches();}}
Time of Update: 2018-07-19
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4415733http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4244499 一個由來已久的bug,但是sun對此似乎並不急於修改,可苦了我們這幫靠java吃飯的人.幸好還有更多樂於奉獻的人,幸好我們也還有很多open source.