java的輸入問題

2007-07-08 8:05 pm
在run一個java program的時候
可以使用args[0], arg[1]這些來輸入文字或數據
例如:C:\\java>java xxx 1 2 3 4
又可以使用readline()
在run的時候去到這一句時會停止並等待別人輸入文字或數據

除了此兩項輸入方法, 有沒有其他例子?

回答 (1)

2007-07-13 1:14 pm
✔ 最佳答案
用 file
e.g. you have a file named "abc.txt"

then you can do: java xxx < abc.txt

then use the readline() again to get the information (didn't try in dos, it works in shell for sure)

you can also do: cat abc.txt | java xxx
which use readline() also. (doesn't work in dos for sure, use unix shell...)

2007-07-13 05:15:08 補充:
assume you have data inside the file...of course...


收錄日期: 2021-04-24 22:58:59
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070708000051KK01352

檢視 Wayback Machine 備份