
2010年9月28日
最近有customer說(shuō)收不到我們系統(tǒng)發(fā)的email,查了一段時(shí)間,總算有所收獲,對(duì)SMTP也有了些許了解。
一開(kāi)始以為是我們郵件服務(wù)器IP被blacklist了或?qū)Ψ桨盐覀兊腎P給禁了。于是就試了下用telnet SMTP測(cè)試下:
telnet #customer.domain.com# 25
EHCO sdfa
MAIL FROM: <
from@xxx.com>
RCPT TO: <
to@xxxxxx.com>
DATA
.
QUIT
結(jié)果測(cè)試我們是可以telnet到對(duì)方的SMTP server的,這樣發(fā)是可以發(fā)送成功的,即排除了對(duì)方把我們禁了的可能。可如果telnet到我們自己的SMTP server的話(huà),就失敗了。
telnet #own.domain.com# 25
...
后來(lái)查了很久,原來(lái)是因?yàn)閠imeout的原因:我們用的IMSS gateway有timeout機(jī)制。查L(zhǎng)og發(fā)現(xiàn),連接對(duì)方SMTP SERVER無(wú)問(wèn)題,MAIL FROM command也無(wú)問(wèn)題,可就在RCPT TO 這個(gè)command超時(shí)了,超過(guò)30s都沒(méi)有response從對(duì)方SMTP SERVER回來(lái),估計(jì)對(duì)方的SMTP SERVER不怎么好,parse和查找個(gè)email address (end user:
to@xxxx.com)都要花很長(zhǎng)時(shí)間。后來(lái)我們就timeout的參數(shù),從30s調(diào)到60s,果然就可以了,估計(jì)對(duì)方SMTP server之行RCPT TO這個(gè)命令都花了30-40s。
問(wèn)題解決
posted @
2011-12-30 00:24 li40204 閱讀(191) |
評(píng)論 (0) |
編輯 收藏
Ubuntu vi 默認(rèn)不支持鍵盤(pán)的方向鍵和Backspace鍵,很不方便,可以修改/etc/vim下面動(dòng)vimrc.tiny,使其支持。
vi /etc/vim/vimrc.tiny
set compatible -> change to
set nocompatible
And add
set backspace=2
posted @
2011-04-20 00:06 li40204 閱讀(350) |
評(píng)論 (1) |
編輯 收藏
1. Always keep data private.
2. Always initialize data.
3. Don't use too many basic types in a class.
4. Not all fields need individual field accessors and mutators.
5. Use a standard form for class definitions.
6. Break up classes with too many responsibilities.
7. Make the names of your classes and methods reflect their responsibilities.
posted @
2010-12-10 13:41 li40204 閱讀(175) |
評(píng)論 (0) |
編輯 收藏
不知不覺(jué)又停了N天學(xué)習(xí),看來(lái)堅(jiān)持對(duì)偶來(lái)說(shuō)真是難于登天啊。。。
The javac compiler always looks for files in the current directory, but the java interpreter only looks into the current directory if the "." directory is on the class path. If you have no class path set, this is not a problem—the default class path consists of the "." directory. But if you have set the class path and forgot to include the "." directory, then your programs will compile without error, but they won't run.
Features tagged as public can be used by any class. Private features can be used only by the class that defines them. If you don't specify either public or private, then the feature (that is, the class, method, or variable) can be accessed by all methods in the same package.
Comment Extraction
Here, docDirectory is the name of the directory where you want the HTML files to go. Follow these steps:
1.
|
Change to the directory that contains the source files you want to document. If you have nested packages to document, such as com.horstmann.corejava, you must be working in the directory that contains the subdirectory com. (This is the directory that contains the overview.html file if you supplied one.)
|
2.
|
Run the command
javadoc -d docDirectory nameOfPackage
for a single package. Or run
javadoc -d docDirectory nameOfPackage1 nameOfPackage2...
to document multiple packages. If your files are in the default package, then instead run
javadoc -d docDirectory *.java
|
posted @
2010-12-10 12:00 li40204 閱讀(165) |
評(píng)論 (0) |
編輯 收藏
用System.out.printf方法進(jìn)行格式化輸出;也可用String.format方法創(chuàng)建一個(gè)格式化的String, 而不需要打印輸出。
日期格式設(shè)置參考Core Java, Volumn 1的P55頁(yè),許多格式化規(guī)則與本地環(huán)境有關(guān)。
java.util.Arrays類(lèi)包含了用來(lái)操作數(shù)組(例如排序與搜索)的各種方法,常用方法如下:
static String toString(type[] a)
static void sort(type[] a) //Quick Sort
static int binarySearcch(type[] a, type v)
static void fill(type[] a, type v) //將數(shù)組的所有數(shù)據(jù)元素值設(shè)為v
....
End of Chapter 3
posted @
2010-10-10 18:10 li40204 閱讀(168) |
評(píng)論 (0) |
編輯 收藏
Java讀取控制臺(tái)System.in 輸入相對(duì)麻煩點(diǎn),要先構(gòu)造一個(gè)Scanner對(duì)象,并與標(biāo)準(zhǔn)輸入流System.in關(guān)聯(lián)。(Scanner包含在包java.util中)
Scanner in = new Scanner(System.in);
System.out.println("What is your name?");
String name = in.nextLine(); //讀整行,因?yàn)榭赡馨崭?br />

//Or
//String name = in.next(); //以空白符為分隔
//int age = in.nextInt(); //讀取整數(shù)
使用Scanner時(shí)輸入是可見(jiàn)的,因此不適用從控制臺(tái)讀取密碼。Console類(lèi)可以實(shí)現(xiàn)這個(gè)目的。
Console cons = System.console();
//Method prototype:
//static String readLine(String prompt, Object
args)
//顯示字符串prompt并且讀取用戶(hù)輸入直到輸入行結(jié)束, args參數(shù)用來(lái)提供輸入格式
String username = cons.readLine("User name: ");
//Method prototype:
//static char[] readPassword(String prompt, Object
args)
//用戶(hù)輸入不可見(jiàn)
char[] pwd = cons.readPassword();
posted @
2010-10-02 17:57 li40204 閱讀(443) |
評(píng)論 (0) |
編輯 收藏
Java中有8種基本數(shù)據(jù)類(lèi)型:int, short, long, byte, float, double, char, boolean
在Java中,整型的范圍與運(yùn)行java代碼的機(jī)器無(wú)關(guān)。在C/C++程序中,int類(lèi)型占用的字節(jié)可能會(huì)因不同機(jī)器不同操作系統(tǒng)而不同;而在java中,各種整型的存儲(chǔ)需求已經(jīng)被明確定義(int: 4 bytes; short: 2 bytes; long: 8 bytes; byte: 1 byte),從而實(shí)現(xiàn)了平臺(tái)無(wú)關(guān)性。
常用整型、浮點(diǎn)型常量:
l Integer.MAX_VALUE
l Ingeger.MIN_VALUE
l Double.POSITIVE_INFINITY (正無(wú)窮大)
l Double.NEGATIVE_INFINITY (負(fù)無(wú)窮大)
l Double.NaN (Not a number)
PS: 判斷一個(gè)特定值是否等于Double.NaN:
if (x == Double.NaN) //is never true
Should use:
if (Double.isNaN(x)) // check whether x is “Not a number”
char 類(lèi)型用于表示Unicode編碼的字符單元。Unicode可表示為16進(jìn)制值,從"u0000到"uffff。
關(guān)于Unicode: 在Unicode出現(xiàn)前,已經(jīng)有了很多的字符編碼標(biāo)準(zhǔn)(如美國(guó)的ASCII, 西歐的ISO 8859-1, 俄羅斯的KOI-8, 中國(guó)的GB118030和BIG-5,etc),這樣造成了兩個(gè)問(wèn)題:a). 對(duì)于給定的代碼值,不同的編碼方案下可能對(duì)應(yīng)不同的字母; b). 采用大字符集的語(yǔ)言其編碼長(zhǎng)度可能不同,e.g., 有些常用的字符采用單字節(jié)編碼,而另一些字符則需要兩個(gè)或更多字節(jié)。設(shè)計(jì)Unicode就是為了解決這些問(wèn)題。但遺憾的是,經(jīng)過(guò)一段時(shí)間,Unicode字符超過(guò)了65536個(gè),現(xiàn)在,連16位的char類(lèi)型也已經(jīng)不能滿(mǎn)足所有Unicode字符的需求了。強(qiáng)烈建議不要在程序中用char類(lèi)型。
當(dāng)將一個(gè)字符串和一個(gè)非字符串的值進(jìn)行拼接時(shí),后者被轉(zhuǎn)換成字符串。E.g:
int age = 24;
String s = “abce” + age; //age被轉(zhuǎn)換成字符串,結(jié)果為“abcd24”。
采用字符串連接的方式時(shí),每次連接字符串,都會(huì)構(gòu)建一個(gè)新的String對(duì)象,既耗時(shí)又浪費(fèi)空間。可以使用StringBuilder代替:
StringBuilder builder = new StringBuilder();
builder.append(ch/str);
其前身是StringBuffer。StringBuffer效率稍低,但支持多線(xiàn)程。StringBuilder不支持多線(xiàn)程,從而效率也較高。
posted @
2010-10-02 17:22 li40204 閱讀(215) |
評(píng)論 (0) |
編輯 收藏
Command: jar xvf file.zip 用于解壓文件。Java庫(kù)源文件在JDK中保存為src.zip,可用該命令解壓。
Javac將.java文件編譯成.class文件,發(fā)送到j(luò)vm, jvm執(zhí)行編譯器存放在.class文件中的字節(jié)碼。
運(yùn)行applet:1). 直接用瀏覽器打開(kāi)html,該html里包含applet。2). appletviewer ***.html。applet嵌入到html的寫(xiě)法如下:
<html>
<head></head>
<body>
......
<applet code = "WelcomeApplet.class" width="400" height="200">
<param name = "greeting" value="Welcome to core java!" />
</applet>
</body>
<html>
posted @
2010-09-28 00:40 li40204 閱讀(187) |
評(píng)論 (0) |
編輯 收藏