Java – Convert InputStream to String

Recently, i have created a simple Java Servlet server which could parse a request xml from the HTTP POST Request and then return the HTTP Response together with the response xml. In the server implementation, i need to convert an InputStream into a String. The following code shows you how to make it.

In this example, the program will read the data.txt file and print the content to the console. Continue reading Java – Convert InputStream to String

非常人語 – 評論員之死

評論員之死 陳雲 曾志豪

年半前陳雲跑上《非常人語》,建議香港徵收物業空置稅, 免地產商囤積吉樓,還說有錢佬恨這政策入骨,誰說誰就死,連最激的議員也不敢提。可惜記者目光狹窄,當時專心寫他嫖妓,遺漏了這點。
 

近來他在《信報》撰寫評論,重提物業空置稅,又叫李家誠實商人下地獄,果然專欄即時死亡,「我知道冒險,有些老人家 好唔老黎, 捐咁多錢只為下世不用受苦,你叫佢落地獄?」四十八歲的陳雲說。
 

同是評論員,陳雲已死,曾志豪半死,他與吳志森主持的《頭條新聞》疑因過激,醞釀換人已久,終於續約三個月吊命,卅二歲的他說:「香港人好善忘,如果到時要郁我哋,可以好合情合理地郁。」 Continue reading 非常人語 – 評論員之死

小王子 Le Petit Prince

作者: Antoine de Saint-Exupéry

地球上每一個人都在追尋生命中的意義,都有誰可以告訴你應該追求什麼?

作者 Antoine de Saint-Exupéry 用最簡單的文字化作一個小王子,讓世人知道生命所追尋的東西其實再簡單不過,而且往往就已經出現係自己身邊。

這書適合任何年齡人士閱讀,特別是那些常說自己忙碌的成年人

健吾 – 他的特別行政區

哲學家,有時比占卜師還要準。黃子華先生的棟篤笑中,他曾經說過他的朋友阿明的故事:

「對阿明來講,香港其實就是李嘉誠,是李家的城,The City Of the Lee’s Family。他的口頭禪就是還差一個字,差一個什麼字呢?香港特別行政區,HKSAR,Hong Kong Special Administrative Region……但是大家想像下,這個HKSAR,如果H,可以變成L,會變成什麼?LKS!Lee Ka Shing Administrative Region!」
 

胡錦濤主席直接接見李嘉誠先生,肯定了他對深圳發展的貢獻,並希望李嘉誠繼續為港深合作發揮影響力。
 

香港現在是什麼人在管?港人治港 、高度自治原來是廢話。 Continue reading 健吾 – 他的特別行政區

世界哲學家叢書 – 柏拉圖

作者: 傅佩榮

柏拉圖深受蘇格拉底影響,繼承了蘇氏的哲學思想並加以發展。此書主要以對話錄 Dialogue中的所講述的事件去分析柏拉圖對多個範疇的思想,包括

  • 知識
  • 理型 Theory of Ideas (Greek: Eidos)
  • 靈魂
  • 愛樂斯 (Greek: Eros)
  • 神明
  • 藝術
  • 快樂
  • 教育
  • 政治

當中的理型(Greek: Eidos)就是柏拉圖哲學的中心思想。其實我都未能完全理解書中所有東西,但大概我都可以領略到些少柏拉圖心中理想國 The Republic的模樣。

C++ – Print CString to cout

The following code shows you how to print CString to cout.

#include "atlstr.h"
#include <iostream>
using namespace std;

int main ()
{
	// Create a CString
	CString cStr = _T("I am a CString.");
	
	// Print the address of cStr only
	cout << cStr << endl;

	// Print the cStr content
	wcout << cStr.GetString() << endl;

	// Pause
	system("PAUSE");

	// Terminate the program:
	return 0;
}

Continue reading C++ – Print CString to cout

iPhone – Add the Return Key for UIKeyboardTypeNumberPad in iPhone SDK 4

A few months ago, i have a post talking about adding a return button for UIKeyboardTypeNumberPad.
iPhone – Add the Return Key for UIKeyboardTypeNumberPad

But that only works in iOS SDK <= 3.2M. After i upgrade it to 4.0, that feature was broken.

It is found that the we have add the observer to the UIKeyboardDidShowNotification instead of UIKeyboardWillShowNotification. Moreover, the view prefix is changed from <UIKeyboard to <UIPeripheralHostView. Here comes the code. Continue reading iPhone – Add the Return Key for UIKeyboardTypeNumberPad in iPhone SDK 4

辭職的人想離開的是人而不是公司

人們離開誰?  領導者往往會認為別人離職跟我無關,但事實上領導者通常就是肇因。資料顯示,高達65%的人是因為他們的主管而離職。我們大可以說員工是離開工作或公司,但事實上他們通常是開除上司。「公司」沒有錯待員工,是人錯待員工;有時同事惹出問題,也會促使他人求去,但員工的頂頭上司往往才是孤立他們的人。
大部分領導者都能讓員工在首次見面時留下良好印象,而且人們對新工作總抱持樂觀態度,希望終能成功。但時間一久,領導者的真面目會露出來,無法維持刻意營造的形象。如果老闆是個蠢蛋,員工遲早會知道。所以,員工會開除什麼樣的上司呢?通常分為以下四類: Continue reading 辭職的人想離開的是人而不是公司

Dream BIG and go for it =)