Time of Update: 2018-07-26
一個曆史項目,客戶要求改ip,由於系統較為久遠,沒有原始碼,通過反編譯後發現ip寫死在類中,反編譯後的代碼基本沒法進行修改,分析了代碼後,發現與ip相關的內容為返回到頁面中的字串,所以,想到了使用Filter,在Filter中處理這些字串,覺得可行,便查詢了一些資料,實驗成功。以下這個類是從網上找到的,實驗成功後發現頁面已經關了,對原作者表示抱歉的同時表示感謝。 package org.mice.ipchange;import
Time of Update: 2018-07-26
1、位元組數群組轉換為字串 byte[] byBuffer = new byte[20];... ...String strRead = new String(byBuffer);strRead = String.copyValueOf(strRead.toCharArray(), 0, byBuffer.length]); 2、字串轉換成位元組數組 byte[] byBuffer = new byte[200];String
Time of Update: 2018-07-26
PAT Advanced Level 1002. A+B for Polynomials (25) Java代碼: import java.util.Iterator;import java.util.Scanner;import java.util.Stack;import java.util.TreeMap;public class Main {public static void main(String[] arg){ Scanner sc
Time of Update: 2018-07-26
1.擷取java工程中src目錄中的檔案 樣本:擷取src目錄下的test.properties檔案 public class GetFileFromSrcPath { public static void main(String[] args) { InputStream is = GetFileFromSrcPath.class.getResourceAsStream("/test.properties"); } } 2
Time of Update: 2018-07-26
String的split方法支援Regex; Regex\s表示匹配任何空白字元,+表示匹配一次或多次。 一、待分割字串 String str = "a b c d e f g"其中,字串中的的空白分別為:單個空格,多個空格,tab定位字元。二、使用一個或多個空格分割字串正確代碼如下:String []
Time of Update: 2018-07-26
字串的三個比較函數 compareTo (string) ,compareToIgnoreCase(String) 及 compareTo(object string) 其傳回值是int類型若,Str1等於參數字串Str2字串,則 返回0;若該Str1按字典順序小於參數字串Str2,則傳回值小於0;若Str1按字典順序 大於參數字串Str2,則傳回值大於0。 public class StringCompareEmp{ public static void
Time of Update: 2018-07-26
項目主要功能: 用java實現的類似rsync項目的檔案同步:A擁有不完整檔案file_half,B擁有完整檔案file_total,A向B發送不完整檔案的校正碼資訊,B利用完整檔案進行分析後返回差異資料區塊,A收到差異資料區塊後與不完整檔案file_half進行重組形成完整檔案file_total_copy。 優點: 同步時傳送的檔案內容只是差異檔案,則可以減少傳輸的資料,減少同步時間(主要減少了網路傳輸時間),當差異塊相對檔案大小很小時,優勢尤為突出。
Time of Update: 2018-07-26
一、前言 眾所周知,無論使用哪一門程式設計語言,和字串打的交道總是非常之多的。如果恰好使用的程式設計語言在字串處理方面,API很全的話,就可以省去很多麻煩。就現在的使用體驗來說,JAVA在字串處理方面還是挺方便的。這篇博文主要是給大家總結一下java中,有關String的那些常見的API,日後大家使用時,可以方便大家查詢。 二、常見API 構造器
Time of Update: 2018-07-26
java.lang.IllegalArgumentException: Document base D:\apache-tomcat-6.0.20\webapps\bookstore does not exist or is not a readable directory at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142) at
Time of Update: 2018-07-26
1 HashMap的資料結構 HashMap實際上是一個鏈表數組,也就是最外層是數組,數組的元素是鏈表。 2 HashMap的put方法: 原始碼如下: <span style="font-size:10px;"> public V put(K key, V value) { //1 如果Key為Null
Time of Update: 2018-07-26
對於properties檔案的讀寫其實也很簡單,只是路徑不太好找,我查了很長時間才查到的,在這裡分享給需要的朋友。 擷取src目錄下的properties檔案的路徑用下面這句代碼: this.getClass().getResource("/config.properties").getPath() /** * 讀取設定檔 * LiChaofei * 2013-1-31 上午9:10:07 * @return */private
Time of Update: 2018-07-26
二分尋找是一種查詢效率非常高的尋找演算法。又稱折半尋找。 起初在資料結構中學習遞迴時實現二分尋找,實際上不用遞迴也可以實現,畢竟遞迴是需要開闢額外的空間的來輔助查詢。本文就介紹兩種方法 二分尋找演算法思想 有序的序列,每次都是以序列的中間位置的數來與待尋找的關鍵字進行比較,每次縮小一半的尋找範圍,直到匹配成功。
Time of Update: 2018-07-26
轉載自:http://ifeve.com/from-javaeye-cpu-cache/ http://ifeve.com/from-javaeye-false-sharing/ CPU是電腦的大腦,它負責執行程式的指令;記憶體負責存資料,包括程式自身資料。記憶體比CPU慢很多,現在擷取記憶體中的一條資料大概需要200多個CPU周期(CPU
Time of Update: 2018-07-26
#!/bin/sh ### BEGIN INIT INFO # Provides: dastask # Required-Start: $ALL # Required-Stop: $ALL # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and stop
Time of Update: 2018-07-26
import java.io.BufferedReader; import java.io.InputStreamReader; /** * JAVA檢測指定的進程是否在運行。 * * @author JAVA世紀網(java2000.net, laozizhu.com) */ public class TestFindProcessOfExe { public static void main(String[] args) {
Time of Update: 2018-07-26
【046-Permutations(求排列)】 【LeetCode-面試演算法經典-Java實現】【所有題目目錄索引】 原題 Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2],
Time of Update: 2018-07-26
http://www.toutiao.com/i6428519152259957250/ 九款Java效能調試工具,有什麼更好、更多的工具,歡迎補充。 NetBeans Profiler NetBeans中可以找到NetBeans Profiler。 NetBeans分析器是NetBeans的擴充,用於為NetBeans IDE提供分析功能。NetBeans IDE是一個開源的整合式開發環境。NetBeans
Time of Update: 2018-07-26
需求是去除一個key為long型,value為元素為integer的list的map的value的值。 public class test1 { public static void main(String[] args) { Map<Long, Integer> map = Maps.newHashMapWithExpectedSize(5); map.put(1l, Objects.hashCode(Lists.newArrayList(1, 2, 3))
Time of Update: 2018-07-26
利用 Java Agent 和 Instrument 技術錄製線上流量 Java Instrument 技術 遇到的難題 自動打包依賴 ClassNotFound 問題 HttpServletRequest body 只能 get 一次 利用 Java Agent 和 Instrument 技術錄製線上流量
Time of Update: 2018-07-26
下面的程式,顯示一個按鈕和一個標籤。每次點擊按鈕時,標籤都將更新。 package hustspy;import javax.swing.*; import java.awt.*;import java.awt.event.*;public class hello implements ActionListener { private static String labelPrefix = "Number of button clicks: