2010年6月14日 星期一

Java 讀檔亂碼

在 Java 中要讀檔案時
通常會這樣寫

BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream("c:/test.txt")));

可是當文字檔儲存的格式為 ANSI 時
在中文繁體的系統需要指定讀進來的格式
不然會產生亂碼
只要將上述程式碼修改為以下即可

BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream("c:/test.txt", "Big5"));
分享

Android 模擬器不能連網路

最近在試玩 Android 時
要利用模擬器連網路卻沒辦法連
產生了 Android Permission denied 的錯誤訊息
原來是在 AndroidManifest.xml 裡面
需要加入一行文字
<uses-permission android:name="android.permission.INTERNET" />

加入之後 Android 模擬器就可以正常連上網了
分享

Apache 不顯示檔案列表

在撰寫 PHP 網站時
若不想讓網站的目錄結構被看到
可以在 Apache 目錄裡的 conf 資料夾中
找到一個 httpd.conf 的檔案
用記事本打開後
在裡面找到下面的這段設定

<directory "C:/AppServ/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks MultiViews ExecCGI

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

<directory "C:/AppServ/www"> 代表是此 C:/AppServ/www 目錄的設定
在下面的 Options Indexes FollowSymLinks MultiViews ExecCGI
將 Indexes 拿掉
變成 Options FollowSymLinks MultiViews ExecCGI
其它人就看不到網站的目錄結構了
分享

2010年1月27日 星期三

Windows XP 旋轉

今天早上開機時,螢幕莫名奇妙旋轉90度,重開機也沒用,我以為是中毒了,我就上網 Google 一下,發現 Windows XP 有個熱鍵是可以旋轉螢幕的,只要按 Ctrl + Alt + Arrow(方向鍵),就可以轉旋螢幕,例如按 Ctrl + Alt + →,就會將螢幕向右轉90度,這個功能還有趣的,大家可以試看看
分享