writefile.java

来自「导出ORACLE数据库对象DDL语句的程序」· Java 代码 · 共 53 行

JAVA
53
字号
package com.icbcsdc.ddlexp.pub.util;

import java.io.File;
import java.io.FileOutputStream;

import javax.swing.JOptionPane;

public class WriteFile{

public static boolean appendFilePath(String filepath,String str){
	try {
		FileOutputStream fs = new FileOutputStream(filepath,true);
		fs.write(str.getBytes());
		fs.flush();
		fs.close();
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		JOptionPane.showMessageDialog(null,"文件写入出错!","错误信息!!",JOptionPane.WARNING_MESSAGE);	
		return false;
	}
}

public static boolean replaceFilePath(String filepath,String str){
	try {
		FileOutputStream fs = new FileOutputStream(filepath,false);
		fs.write(str.getBytes());
		fs.flush();
		fs.close();
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		JOptionPane.showMessageDialog(null,"文件写入出错!","错误信息!!",JOptionPane.WARNING_MESSAGE);	
		return false;
	}
}

public static boolean appendFile(File file,String str){
	try {
		FileOutputStream fs = new FileOutputStream(file,true);
		fs.write(str.getBytes());
		fs.flush();
		fs.close();
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		JOptionPane.showMessageDialog(null,"文件写入出错!","错误信息!!",JOptionPane.WARNING_MESSAGE);	
		return false;
	}
}

}

⌨️ 快捷键说明

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