* bufferedreader轉換成string
* 注意:流關閉需要自行處理
* @param reader
* @return string
* @throws ioexception
public static string bufferedreader2string(bufferedreader reader) throws ioexception else {
out.write(data, off, len);
off += len;
datalen -= len;
// 重新整理緩衝區
out.flush();
* 字串轉換成char陣列
* @param str
* @return char
public static char str2chararray(string str) {
if(null == str) return null;
return str.tochararray();
public static inputstream string2inputstream(string str) {
return new bytearrayinputstream(str.getbytes());
* inputstream轉換成byte
* 注意:流關閉需要自行處理
* @param in
* @return byte
* @throws exception
public static byte inputstreamtobyte(inputstream in) throws ioexception{
int buffer_size = 4096;
bytearrayoutputstream outstream = new bytearrayoutputstream();
byte data = new byte[buffer_size];
int count = -1;
while((count = in.read(data,0,buffer_size)) != -1)
outstream.write(data, 0, count);
data = null;
byte outbyte = outstream.tobytearray();
outstream.close();
return outbyte;
* inputstream轉換成string
* 注意:流關閉需要自行處理
* @param in
* @param encoding 編碼
* @return string
* @throws exception
public static string inputstreamtostring(inputstream in,string encoding) throws ioexception{
return new string(inputstreamtobyte(in),encoding);
C 讀取檔案流
using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.linq using system.text u...
node csv檔案流讀取
csv檔案流讀取,可以應對大檔案,資料截斷傳送,不會出現記憶體不足的情況 function user,date,filepath,callback var item fg var dbflag true var getcount 0 var tcount 0 api獲取資料條數 var otherc...
io流檔案的讀取
在activity類中定義了openfileinput string name 跟openfileoutput string name,int mode 可以用來進行io流檔案的操作 而且缺省會儲存在記憶體卡當中,下面是 public class fileoperate extends activi...