當前位置:成語大全網 - 書法字典 - Java改變文件內容

Java改變文件內容

導入Java . io . buffered reader;

導入Java . io . file;

導入Java . io . file output stream;

導入Java . io . filereader;

導入Java . io . output streamwriter;

公共類FileInOutput {

/**

* @param args

*/

公共靜態void main(String[] args) {

嘗試{

buffered reader br = new buffered reader(new FileReader(" d:\ \ TT . CVS "));

file f = new Java . io . file(" d:\ \ mm . CVS ");

file output stream fos = new file output stream(f);

output streamwriter OSW = new output streamwriter(fos);

if(OSW = = null)system . out . println(" OSW為null ");

br . readline();

int c = 0;

while(真)

{

c = br . read();

if(c == -1)破;

if(c =='\ " ')繼續;

OSW . write(c);

}

br . close();

OSW . close();

fos . close();

System.out.println("操作完成");

} catch(異常e) {

// TODO自動生成的catch塊

e . printstacktrace();

}

}

}