File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Store contents from JTable into a text file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Store contents from JTable into a text file." Watch "Store contents from JTable into a text file." New topic
Author

Store contents from JTable into a text file.

Sherly Changappa
Greenhorn

Joined: Mar 26, 2013
Posts: 4
Hello ,
I have written a swings form with 5 text boxes and a button. When i click the button save, the data entered is being displayed in the table. Now i want to store the data shown in the table into a text file. Can anyone please help me with this code. I am still a java beginner and have very less idea about java coding. After lot of surfing, i was able to do the table part. I am attaching the code done so far. Please excuse if i have done some silly mistakes. Really in need of your help. Thanks in advance..



Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1479
    
    6

Could you please post your code inside code tags. It would be easier us to read. Now coming to your question, you could have a function like this to store the contents in file.



You can call the above function once you assign the data to the table.


Swastik
Sherly Changappa
Greenhorn

Joined: Mar 26, 2013
Posts: 4
Thank you sir. Your help is greatly appreciated. I'm sorry for the inconvenience made. I'm new to this forum and so dint know the format of posting. Will keep that in mind next time.
Can you please give me a sample snippet of the code you just mentioned. Finding hard to understand so.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Swastik Dey wrote:Could you please post your code inside code tags. It would be easier us to read. . . .
He did, but didn’t use them correctly. Unfortunately when I corrected the code tags, it simply highlighted the lack of indentation.

You didn’t comment on the empty catch block. Nor on trying to catch an Exception as opposed to a specific type of Exception. Nor on catching Exception when it was not declared in a throws clause.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Store contents from JTable into a text file.