/* * Created on 2006-9-26 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package com.pss.test.sep;import java.io.File; import java.io.FileWriter;import com.pss.util.prints.Conica;/** * @author Administrator * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class Test1 { public static void main(String[] args) { String fileName = "d:/Student.txt"; String content = "POPOANTOT"; File file = new File(fileName); if(!file.exists()) { Conica.pl("Not exists, to write..."); doWrite(fileName, content); Conica.pl("Write suecess!"); } else { Conica.pl("Exists, to replace..."); String value = content.replaceAll("O", "INT"); doWrite(fileName, value); Conica.pl("Replace suecess!"); } }
* Created on 2006-9-26
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.pss.test.sep;import java.io.File;
import java.io.FileWriter;import com.pss.util.prints.Conica;/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Test1 { public static void main(String[] args) {
String fileName = "d:/Student.txt";
String content = "POPOANTOT";
File file = new File(fileName);
if(!file.exists()) {
Conica.pl("Not exists, to write...");
doWrite(fileName, content);
Conica.pl("Write suecess!");
} else {
Conica.pl("Exists, to replace...");
String value = content.replaceAll("O", "INT");
doWrite(fileName, value);
Conica.pl("Replace suecess!");
}
}
public static void doWrite(String fileName, String content) {
try {
FileWriter fos = new FileWriter(fileName);
fos.write(content);
fos.close();
} catch (Exception ex) {
}
}
}