read 和write
生活随笔
收集整理的這篇文章主要介紹了
read 和write
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
read:
import java.io.FileReader; ? ? ? ? ? ? //導入包
import java.io.IOException;? ? ? ? ? //導入包
public class read { ??
package com.chinasoft.java.wangluobiancheng;import java.io.FileReader; import java.io.IOException;public class read {public static void main(String []args)throws IOException{FileReader f2=new FileReader("haha1.txt");int i= f2.read();while(i!=-1){System.out.print((char)i);i=f2.read();}//while((f2.read())!=-1){// System.out.print((char)f2.read());//} f2.close();}}write:
import java.io.File; import java.io.FileWriter; import java.io.IOException; public class write {public static void main(String[] args) throws IOException {// TODO Auto-generated method stub FileWriter f1=new FileWriter("haha1.txt"); String str="hahahha";f1.write("hahahha");f1.flush();f1.close();}}?
轉載于:https://www.cnblogs.com/-strong/p/7084711.html
總結
以上是生活随笔為你收集整理的read 和write的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Sublime Text快捷键去除空白行
- 下一篇: mongodb 怎样检测 安装成功 以