package test;
import java.awt.BorderLayout;
import java.io.FileReader;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class Outacc extends JFrame
{
private static final long serialVersionUID = 1L;
private static final String PATHNAME = "D:/Documents/account1.txt";
private static final String LINE = System.getProperty ("line.separator");
public Outacc ()
{
JTextArea ta = new JTextArea ();
ta.setWrapStyleWord (true);
JScrollPane scrollPane = new JScrollPane (ta);
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
setTitle ("我的账单");
setSize (200, 500);
setResizable (false);
setLocationRelativeTo (null);
setLayout (new BorderLayout ());
add (scrollPane, BorderLayout.CENTER);
int s = -1;
FileReader fr = null;
try
{
fr = new FileReader (PATHNAME);
ta.setText ("金额 备注 日期" + LINE);
while (( s = fr.read () ) != -1)
{
ta.append ((char) s + "\t" + LINE);
}
fr.close ();
}
catch (Exception e)
{}
setVisible (true);
}
public static void main ( String args[] )
{
new Outacc ();
}
}
有个getText()的方法。去试试