?? writetxt.java~18~
字號:
package com.util;
import javax.swing.JTable;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.*;
/**
* <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();
String n = "---------------------------------------------------------------------------------------------------------";
for (int i = 0; i < jTable1.getRowCount(); i++) {
String s = "";
if (jTable1.getValueAt(i, 0) == null) {
break;
}
for (int j = 0; j < jTable1.getColumnCount() - 1; j++) {
if (jTable1.getValueAt(i, j) != null) {
s+= jTable1.getValueAt(i, j)+" ";
}else{
s+=" ";
}
}
bw.write(s);
bw.newLine();
bw.write(n);
bw.newLine();
path = file.getAbsolutePath();
}
}
catch (Exception ex) {
ex.printStackTrace();
}
finally {
try {
bw.close();
fw.close();
}
catch (IOException ex1) {
ex1.printStackTrace();
}
}
return path;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -