⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filereadwritetest.java

📁 这个是我们做土地局的一个项目。感觉不错。欢迎下载
💻 JAVA
字号:
package myprojects.getmacaddress;
import java.io.*;

public class FileReadWriteTest {  
  private String mulu;
  public void setMulu(String string)
  {
  	   this.mulu=string;
  	 }
 
  public void WriteMyFile(String str) { 
 // String str="[B@1650d6";
  //byte[] a= ;
  //String str=new String([B@1650d6);
     try { 
FileWriter fw = new FileWriter(mulu);
PrintWriter out = new PrintWriter(fw);    
//out.print("hi,this will be wirte into the file!");  
 out.print(str);
out.close();
fw.close();
     } catch (IOException e) { 
         System.out.println("Uh oh, got an IOException error!");
         e.printStackTrace();
     }
} 

public   String readMyFile() { //str Ŀ¼
    String all="";
    String record = null;
    //int recCount = 0; 
    try { 
FileReader fr = new FileReader(mulu);
       BufferedReader br = new BufferedReader(fr);
       record = new String();
       while ((record = br.readLine()) != null) {
       	all=all+record;
       //  recCount++;
       //  System.out.println(recCount + ": " + record); 
  
	 // System.out.println( record); 
}
br.close();
fr.close(); 
     } catch (IOException e) { 
        //System.out.println("Uh oh, got an IOException error!");
	
		
         e.printStackTrace();
     }
     return all;
} 

  
}    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -