📄 writetxt.java~3~
字号:
package com.util;
import javax.swing.JTable;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class WriteTxt {
public WriteTxt() {
}
public String writeTableOrTxt(String url,JTable jTable1){
String path ="";
File file = new File(url+".txt");
FileWriter fw = null;
BufferedWriter bw = null;
try {
fw = new FileWriter(file);
bw = new BufferedWriter(fw);
String biaoTu=" 资产编号 | 资产名称 | 大类名称 | 小类名称 | 价格 | 购入日期 | 状态 | 购入人 | 使用状态 | 备注 ";
bw.write(biaoTu);
bw.newLine();
for (int i = 0; i < jTable1.getRowCount(); i++) {
String s = "";
for (int j = 0; j < jTable1.getColumnCount(); j++) {
if (jTable1.getValueAt(i,j)!=null) {
s +=jTable1.getValueAt(i,j);
}else{
s +=" ";
}
bw.write(s);
bw.newLine();
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}finally{
}
return path;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -