流的基本使用FileInputStream

2021-09-03 07:39:15 字數 913 閱讀 5086

從硬碟存在的乙個檔案中,讀取其內容到程式中,使用fileinputstream

**

@test

public

void

testfileinputstream1()

throws ioexception

//精簡版本

int b;

while

((b = fileinputstream.

read()

)!=-1

)//4. 關閉相應的流

fileinputstream.

close()

;}

修改版本使用 try-catch的方式處理異常更加合理,保證流的關閉操作一定能夠執行

@test

public

void

testfileinputstream2()

}catch

(ioexception e)

finally

catch

(ioexception e)

}}

開發中使用的方式

@test

public

void

test3()

string str =

newstring

(bytes,

0, len)

; system.out.

print

(str);}

}catch

(ioexception e)

finally

catch

(ioexception e)}}

}

fileinput使用心得

下咋以及一些具體使用過程就不敘述了,簡單說一下使用時候需要注意的幾點 1.在js中封裝好的fileinput函式 初始化fileinput控制項 第一次初始化 type 不同類別 initvalue 初始化值 多圖以,分割 item num 呼叫fileinput的元素 function initf...

LayUI流載入的基本使用

首先在html頁面中定義乙個存放載入內容的標籤 頁面樣式可以根據自己需求進行除錯 使用js根據上面給定的標籤,渲染插入資料。如下。layui.use flow function function res pages為ajax返回的總頁數,只有當前頁小於總頁數的情況下,才會繼續出現載入更多 next ...

使用fileinput模組進行原地修改檔案

現有乙個包含使用者資訊的檔案userinfo,內容格式如下 insert into userinfo id,username,pwdhash,usealias,alias,realname,inuse,f branch id,mobilephone,telephone,email,licenseco...