需要準備的工具:
1. 待轉換的png圖片一張
2. power point 2007
教程請看此網站
教學 : 小畫家圖片-背景透明
2011年3月16日 星期三
2011年2月21日 星期一
Java text append to Linux txt format
在用Java的JTextArea時,如果想將輸出的檔案可在Linux下開啟不要亂碼,換行是用'\n'。
但是單純用String tempstring = tempstring + '\n';的話,tempstring最後4個bytes的16進位會是"00 0A"(用PsPad HEX開可看到),而在Linux上的話就會因為多出了那個"00"而導致亂碼產生,所以必須寫這樣的程式去轉換,使得tempstring最後2個bytes的16進位會是"0A"就好,要去掉"00"。
/////////////////////////////////////////////////
byte[] byteData = new byte[orgstring.length()];
for ( int i = 0 ; i < orgstring.length(); i++) {
byteData[i] = (byte)orgstring.charAt(i);
} // for
byteData[orgstring.length()-1] = 0x0A;
String strResult = new String(byteData);
textarea.append(strResult);
/////////////////////////////////////////////////
但是單純用String tempstring = tempstring + '\n';的話,tempstring最後4個bytes的16進位會是"00 0A"(用PsPad HEX開可看到),而在Linux上的話就會因為多出了那個"00"而導致亂碼產生,所以必須寫這樣的程式去轉換,使得tempstring最後2個bytes的16進位會是"0A"就好,要去掉"00"。
/////////////////////////////////////////////////
byte[] byteData = new byte[orgstring.length()];
for ( int i = 0 ; i < orgstring.length(); i++) {
byteData[i] = (byte)orgstring.charAt(i);
} // for
byteData[orgstring.length()-1] = 0x0A;
String strResult = new String(byteData);
textarea.append(strResult);
/////////////////////////////////////////////////
訂閱:
文章 (Atom)