delimiter()
返回此 scanner 當前正在用於匹配分隔符的 pattern。
hasnext()
判斷掃瞄器中當前掃瞄位置後是否還存在下一段。
hasnextline()
如果在此掃瞄器的輸入中存在另一行,則返回 true。
next()
查詢並返回來自此掃瞄器的下乙個完整標記。
nextline()
此掃瞄器執行當前行,並返回跳過的輸入資訊。
public class inputtest
3.檔案的輸出scanner in=new scanner(new file(「d:\test.txt」));
@ 注釋:scanner預設使用空格作為分割符來分隔文字,但允許你指定新的分隔符
使用預設的空格分隔符:
public static void main(string args) throws filenotfoundexception
}123
asdf
sd 45
789
sdf
asdfl,sdf.sdfl,asdf
……asdfkl
las
process finished with exit code 0
將注釋行去掉,使用空格或逗號或點號作為分隔符,輸出結果如下:
123
asdf
sd 45
789
sdf
asdfl
sdf
sdfl
asdf
asdfkl
las
process finished with exit code 0
java輸入輸出
1。file 描述了檔案本身的屬性,無關流操作。iffile,isabsolute 絕對路徑否 delete,isdirectory,list 字串形式列出目錄內容 listfiles 以file物件陣列形式返回檔案列表 mkdir,mkdirs 建立目錄以及此目錄的所有父目錄 filenamefi...
java輸入輸出
一 file 類 1.構造方法 files file parent,string child 根據parent抽象路徑名和child路徑名建立新file例項 file string pathname 通過給定路徑名字字串轉換為抽象路徑名來建立乙個新file例項。file string parent,...
Java輸入輸出
從控制台讀取 1.普通讀取 scanner in new scanner system.in 2.讀取密碼 console cons system.console next 與 hasnext 的區別 string next 讀取輸入的下乙個單詞,以空格作為分隔符,返回輸入的字串 boolean h...