码迷,mamicode.com
首页 > 其他好文 > 详细

IO操作基本步骤

时间:2019-10-27 16:39:31      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:gen   基本   str   com   not   exce   system   package   for   

package com.study02;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class IOtest03 {
public static void main(String[] args) {
File src = new File("abc.txt");
FileInputStream is = null;
try {
is = new FileInputStream(src);

for (int i = is.read(); i != -1; i=is.read()) {
System.out.print((char)i);
}

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
if (is!=null) {
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

}
}

IO操作基本步骤

标签:gen   基本   str   com   not   exce   system   package   for   

原文地址:https://www.cnblogs.com/LuJunlong/p/11747642.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!