Time of Update: 2015-07-11
標籤:DecimalFormat可以用來格式化數字,例如用來設定保留多少位小數、設定數字分隔字元等。說方法之前,先介紹一下其常用的幾個模式預留位置:0 一個數字# 一個數字,不包括 0. 小數的分隔字元的預留位置, 分組分隔字元的預留位置這裡用一個簡單的例子來說明其使用方法: public static void main(String[] args) { DecimalFormat df1 = new DecimalFormat("#.#");
Time of Update: 2015-07-11
標籤:Java知識簡介與環境變數配置問題一、在學習一門語言中,不僅需要掌握其文法結構,開發平台以及環境也是很重要的。在開始Java學習之前首先對其進行壓縮包的下載安裝,以及開發平台環境下載安裝。基於此下面文章就此展開:1、 下載並安裝JDK包,然後進行快速正確安裝操作。(具體安裝步驟網上很多,不在贅述。)2、
Time of Update: 2015-07-11
標籤:原文 JAVA實現AES的加密和解密演算法import javax.crypto.Cipher;import javax.crypto.spec.IvParameterSpec;import javax.crypto.spec.SecretKeySpec;import sun.misc.BASE64Decoder;import sun.misc.BASE64Encoder;/** * AES 是一種可逆密碼編譯演算法,對使用者的敏感資訊加密處理 *
Time of Update: 2015-07-11
標籤:1,安裝rabbitmq.我的是ubuntu14.04,在官網上面下載最新的安裝檔案http://www.rabbitmq.com/install-debian.html2.安裝完之後 啟動rabbitmq, sudo rabbitmq-server 3.下載jar包 4.最簡單的hello world的實現Sender類package com.lubby.test;import java.io.IOException;import
Time of Update: 2015-07-11
標籤: Jar (Java Archive File, java歸檔檔案),它其實也是一個zip檔案。它包括了一個可選的META-INF目錄。可以使用命令列中的jar命令來產生一個jar檔案,也可以使用java.util.jar
Time of Update: 2015-07-11
標籤:原文: 分享非常有用的Java程式(關鍵代碼)(七)---抓屏程式 import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import javax.imageio.ImageIO;
Time of Update: 2015-07-11
標籤:原文: 分享非常有用的Java程式 (關鍵代碼)(五)---把 Array 轉換成 Map import java.util.Map; import org.apache.commons.lang.ArrayUtils; public class Main { public static void main(String[] args) { String[][] countries =
Time of Update: 2015-07-11
標籤:package com.silianbo;/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */import java.awt.BorderLayout;import
Time of Update: 2015-07-11
標籤:原文: 分享非常有用的Java程式 (關鍵代碼)(六)---解析/讀取XML 檔案(重要) XML檔案 <?xml version="1.0"?> <students> <student> <name>John</name> <grade>B</grade>
Time of Update: 2015-07-11
標籤:原文: 分享非常有用的Java程式 (關鍵代碼) (三)---建立ZIP和JAR檔案 import java.util.zip.*; import java.io.*; public class ZipIt { public static void main(String args[]) throws IOException { if (args.length < 2) {
Time of Update: 2015-07-11
標籤:原文: 分享非常有用的Java程式 (關鍵代碼) (一) 分享一些非常有用的Java程式 (關鍵代碼) ,希望對你有所協助。1. 得到當前方法的名字String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); 2. 轉字串到日期java.util.Date =
Time of Update: 2015-07-11
標籤:原文: 分享非常有用的Java程式 (關鍵代碼) (二)---列出檔案和目錄 File dir = new File("directoryName"); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory }
Time of Update: 2015-07-11
標籤:enum關鍵字用於定義枚舉類,若枚舉只有一個成員, 則可以作為一種單例模式的實現方式。 枚舉類對象的屬性不應允許被改動, 所以應該使用 private final 修飾。枚舉類的使用 private final 修飾的屬性應該在構造器中為其賦值。若枚舉類顯式的定義了帶參數的構造器, 則在列出枚舉值時也必須對應的傳入參數。 必須在枚舉類的第一行聲明枚舉類對象。枚舉類和普通類的區別: 1.使用
Time of Update: 2015-07-11
標籤:很久之前做的一個東西,現在拿出來整理一下放在自己的部落格中!一. 設計目的隨著人互連網的發展,人和人之間的溝通方式也越來越便捷和多樣化,線上聊天工具已經成為人們生活中夠通不可缺少的部分,在學習完java網路編程課程,如果能開發一款屬於自己的聊天工具,和好友進行私密對話,則是一件令人興奮的事。同時,安全可靠的TCP這兩種通訊協定,是非常重要的內容,值得研究。二. 設計內容本聊天室程式基於C/S模式,聊天室共分為伺服器端和用戶端兩部分,伺服器端程式主要負責偵聽用戶端發來的訊
Time of Update: 2015-07-11
標籤:原文: 分享非常有用的Java程式 (關鍵代碼)(四)---動態改變數組的大小 /** * Reallocates an array with a new size, and copies the contents * * of the old array to the new array. * * @param oldArray the old array, to be reallocated. * *
Time of Update: 2015-07-11
標籤:violate在多線程當中的用來修飾某個變數,這個變數只有一份,也就是不存在多線程cache它們本地的情況出現。從而保證對他的讀和寫是唯一的,不會存在不一致的情況。一、適用的情況對於某個變數只有讀和寫兩種單一操作。violate int
Time of Update: 2015-07-11
標籤:原文: 分享非常有用的Java程式(關鍵代碼)(八)---Java InputStream讀取網路響應Response資料的方法!(重要) Java InputStream讀取資料問題======================================================================原理講解 1. 關於InputStream.read()
Time of Update: 2015-07-11
標籤:leetcode java divide two integers 題目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return
Time of Update: 2015-07-11
標籤:leetcode java substring with conca 題目:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s)
Time of Update: 2015-07-11
標籤:1、java 的工作方式、包、jar 封存檔案和部署最簡單的,原始碼—>編譯器—>輸出—>java 虛擬機器(JVM)。javac Party.javajava Party將原始碼和類檔案分離,原始碼(.java)儲存在source目錄下,輸出(.class)產生在 classes 目錄。cd MyProject/sourcejavac -d ../classes *.javacd MyProject/classesjava