标题:计算机毕业设计中Java实现本地读写文件
package com.shaonaiyi.local;import java.io.File;import java.io.FileOutputStream;/*** Java实现本地写文件*/public class WriteFile {public static void main(String[] args) throws Exception{String path = "/Users/shaonaiyi/datas/tmp/hello.txt";//win系统// String path = "c:\\hello.txt";File file = new File(path);String content = "hello,shaonaiyi.\n";FileOutputStream fileOutputStream = new FileOutputStream(file);fileOutputStream.write(content.getBytes());fileOutputStream.close();}}
package com.shaonaiyi.local;import java.io.BufferedReader;import java.io.FileInputStream;import java.io.InputStreamReader;/*** Java实现本地读文件*/public class ReadFile {public static void main(String[] args) throws Exception{String path = "/Users/shaonaiyi/datas/tmp/hello.txt";//win系统// String path = "c:\\hello.txt";FileInputStream fileInputStream = new FileInputStream(path);BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));String line = null;while ((line = bufferedReader.readLine()) != null) {System.out.println(line);}fileInputStream.close();}}
0xFF 总结
请与HDFS的读写做个比较:
IntelliJ IDEA实现Hadoop读写HDFS文件(非Maven、离线版)
Java API实现HDFS的相关操作
作者简介:邵奈一
全栈工程师、市场洞察者、专栏编辑
公众号、微博、CSDN:邵奈一
福利:
邵奈一的技术博客导航
————————————————
版权声明:本文为CSDN博主「邵奈一」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/shaock2018/article/details/90607893
更多请关注小编继续了解,免费赠送网页设计作业源代码哦!
版权所有© 帮我毕业网 并保留所有权利