public class TestFileInputStream {
public static void main(String [] args) {
//读取指定文件中内容,并在控制台输出
FileInputStream fis = null;
byte[] b = new byte[1024];
int len = 0;
try {
fis = new FileInputStream("E:\\javafile\\ja.txt");
while((len = fis.read(b)) != -1) {
System.out.write(b, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public class TestFileInputStream{
public static void main(String [] args) {
//实现文件复制
FileInputStream fis = null;
FileOutputStream fos = null;
byte[] b = new byte[1024];
int len = 0;
try {
fis = new FileInputStream("E:\\javafile\\ja.txt");
fos = new FileOutputStream("E:\\javafile\\jc.txt");
while((len = fis.read(b)) != -1) {
fos.write(b, 0, len);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch(IOException io) {
io.printStackTrace();
}finally {
try {
fis.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
java输出文件路径 java读取文件内容到控制台
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
jquery怎么在href链接里带参数
在a标签里添加data-ajax="false"或rel="external"属性例:<a data-ajax="false" href="http://www.***.com/help/***.zip">点击下载</a>详解: 外部页面链接JQuery Mobile 主动化了创建ajax站点和法度的过程.默认景象下,当你点击一个链接时会指向
jquery怎么在href链接里带参数 python javascript ViewUI ajax