📄 readfile.java
字号:
// Readfile.java
// 僼傽僀儖偺撪梕傪撉傒庢傝,偦偺傑傑夋柺偵弌椡偟傑偡
// 巊偄曽java Readfile 僼傽僀儖柤
//儔僀僽儔儕偺棙梡
import java.io.*;
// Readfile僋儔僗
public class Readfile {
// 僾儘僌儔儉偺杮懱main
public static void main(String[] args){
byte[] buff = new byte[1024];//攝楍偺掕媊
boolean cont = true ;// 儖乕僾惂屼梡曄悢
FileInputStream infile = null;// 僼傽僀儖撉庢梡
// 僆僽僕僃僋僩infile傪嶌傝,僼傽僀儖撉傒弌偟傪弨旛偟傑偡
try{
infile = new FileInputStream(args[0]) ;
}
catch(FileNotFoundException e){
// 僼傽僀儖弨旛偺幐攕
System.err.println("僼傽僀儖偑偁傝傑偣傫") ;
System.exit(1) ;
}
// 僼傽僀儖偺廔椆傑偱,埲壓偺儖乕僾傪孞傝曉偟傑偡
while (cont) {
try {
// 僼傽僀儖偐傜偺撉傒崬傒
int n = infile.read(buff);
// System.out傊偺彂偒弌偟
System.out.write(buff, 0, n) ;
}
// 埲壓偼椺奜張棟偱偡
catch(Exception e){
// 撉傒弌偟廔椆帪偵儖乕僾傕廔椆偟傑偡
cont = false ;
}
}
// 僼傽僀儖傪暵偠傑偡
try{
infile.close() ;
}
catch(IOException e){
// 僼傽僀儖僋儘乕僘偺幐攕偱偡
System.err.println("僼傽僀儖偺僄儔乕偱偡") ;
System.exit(1) ;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -