JTable data back-up

Hi!
I'm currently using preferences API to back-up my jTable (lots of coding).
can I back up my entire jTable with single serialization file?
    try {
      FileOutputStream fos = new FileOutputStream (jTable);
      ObjectOutputStream oos = new ObjectOutputStream (fos);
      oos.writeObject (table.ser); 
      oos.flush();
      oos.close();
          } catch (IOException e) {
            e.printStackTrace();
}

can you show me an example of how that is done?Sorry, I don't feel like writing the code, but I
would guess that opening a file, writing a loop,
write some data, and close the file is done inless
than 30-40 lines of code.
KajWhen you say "write a loop" do you infer that the
data must be extracted by row and column coordinates?Yes

Similar Messages

  • JTable data back-up (re-visited)

    Hi!
    I need to persist the data in my jTable rows and columns. Right now I get and set them with java preferences with two x and y loops ... this works fine.
    but ..... is there a way to save to a file the jTable row and column data without first extracting the row and column data cell for cell?
    ie; to serialize only the cell data?

    Thanks!
    Is there an example code for me to look at? (didnt see much on Google so far)

  • Java.io.NotSerializableException when overwrite the JTable data into .txt file

    hi everyone
    this is my first time to get help from sun forums
    i had java.io.NotSerializableException: java.lang.reflect.Constructor error when overwrite the JTable data into .txt file.
    At the beginning, the code will be generate successfully and the jtable will be showing out with the data that been save in the studio1.txt previously,
    but after i edit the data at the JTable, and when i trying to click the save button, the error had been showing out and i cannot succeed to save the JTable with the latest data.
    After this error, the code can't be run again and i had to copy the studio1.txt again to let the code run 1 more time.
    I hope i can get any solution at here and this will be very useful for me.
    the following is my code...some of it i create it with the GUI netbean
    but i dunno how to attach my .txt file with this forum
    did anyone need the .txt file?
    this is the code that suspect maybe some error here
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String filename = "studio1.txt";
              try {
                  FileOutputStream fos = new FileOutputStream(new File(filename));
                  ObjectOutputStream oos = new ObjectOutputStream(fos);
                   oos.writeObject(jTable2);
                   oos.close();
              catch(IOException e) {
                   System.out.println("Problem creating table file: " + e);
                   return;
              System.out.println("JTable correctly saved to file " + filename);
    }the full code will be at the next msg

    this is the part 1 of the code
    this is the full code...i had /*....*/ some of it to make it easier for reading
    package gui;
    import javax.swing.*;
    import java.io.*;
    public class timetables extends javax.swing.JFrame {
        public timetables() {
            initComponents();
        @SuppressWarnings("unchecked")
        private void initComponents() {
            jDialog1 = new javax.swing.JDialog();
            buttonGroup1 = new javax.swing.ButtonGroup();
            buttonGroup2 = new javax.swing.ButtonGroup();
            buttonGroup3 = new javax.swing.ButtonGroup();
            buttonGroup4 = new javax.swing.ButtonGroup();
            jTextField1 = new javax.swing.JTextField();
            jLayeredPane1 = new javax.swing.JLayeredPane();
            jLabel6 = new javax.swing.JLabel();
            jTabbedPane1 = new javax.swing.JTabbedPane();
            jScrollPane3 = new javax.swing.JScrollPane();
            jTable2 = new javax.swing.JTable();
            jScrollPane4 = new javax.swing.JScrollPane();
            jTable3 = new javax.swing.JTable();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
    /*       org.jdesktop.layout.GroupLayout jDialog1Layout = new org.jdesktop.layout.GroupLayout(jDialog1.getContentPane());
            jDialog1.getContentPane().setLayout(jDialog1Layout);
            jDialog1Layout.setHorizontalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
            jDialog1Layout.setVerticalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jLayeredPane1.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);
            String filename1 = "studio1.txt";
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable2 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable3 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            jTable2.setRowHeight(20);
            jTable3.setRowHeight(20);
            jScrollPane3.setViewportView(jTable2);
            jScrollPane4.setViewportView(jTable3);
            jTable2.getColumnModel().getColumn(4).setResizable(false);
            jTable3.getColumnModel().getColumn(4).setResizable(false);
            jTabbedPane1.addTab("STUDIO 1", jScrollPane3);
            jTabbedPane1.addTab("STUDIO 2", jScrollPane4);
            jTextField1.setText("again n again");
            jLabel6.setText("jLabel5");
            jLabel6.setBounds(0, 0, -1, -1);
            jButton2.setText("jButton2");
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
          

  • Java.io.NotSerializableException when overwrite the JTable data into .txt

    hi everyone
    i had java.io.NotSerializableException: java.lang.reflect.Constructor error when overwrite the JTable data into .txt file.
    At the beginning, the code will be generate successfully and the jtable
    will be showing out with the data that been save in the studio1.txt
    previously,
    but after i edit the data at the JTable, and when i trying to click the
    save button, the error had been showing out and i cannot succeed to
    save the JTable with the latest data.
    After this error, the code can't be run again and i had to copy the studio1.txt again to let the code run 1 more time.
    I hope i can get any solution at here and this will be very useful for me.
    but i dunno how to attach my .txt file with this forum
    did anyone need the .txt file?
    the following is my suspect code
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String filename1 = "studio1.txt";
              try {
                  FileOutputStream fos = new FileOutputStream(new File(filename1));
                  ObjectOutputStream oos = new ObjectOutputStream(fos);
                   oos.writeObject(jTable2.getModel());
                   oos.flush();
                   oos.close();
                   fos.close();
              catch(IOException e) {
                   System.out.println("Problem creating table file: " + e);
                            e.printStackTrace();
                   return;
              System.out.println("JTable correctly saved to file " + filename1);
    }this is the reading code
    String filename1="studio1.txt";
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   TableModel model = (TableModel)ois.readObject();
                    jTable3.setModel(model);
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
              }Edited by: Taufulou on Jan 8, 2009 11:43 PM
    Edited by: Taufulou on Jan 8, 2009 11:44 PM
    Edited by: Taufulou on Jan 8, 2009 11:45 PM

    is this the code u mean?
    i had put this code inside it but the problem still remain the same
    if (jTable2.isEditing()) {
                jTable2.getCellEditor().stopCellEditing();
            }i had found a new thing that when i just double click the cell without change any data inside the table
    and click the button "Save". the same exception which is
    java.io.NotSerializableException: java.lang.reflect.Constructor
    will come out again.

  • TS3988 My wife bought an iPad Air and synced contact from our PC (Outlook), now all our contacts in Outlook have gone and we have to go to iCloud to get them, and even then they are a bit jumbled. How do I get my data back onto my PC?

    My wife bought an iPad Air and synced contact from our PC (Outlook), now all our contacts in Outlook have gone and we have to go to iCloud to get them, and even then they are a bit jumbled. How do I get my data back onto my PC?

    If you can see the iCloud contacts in Outlook, you can copy them back to your PC by selecting all the contacts (click one, then press Control-A), then drag and drop the selected contacts to Contacts under My Contacts on the left sidebar of Outlook.
    If you want to copy your calendar back to Outlook, select your iCloud calendar on the left sidebar of Outlook, switch to the list view (select View from the ribbon, then click Change View>List), select your events (click on a single event, then press Control-A), then control drag and drop them to Calendar under My Calendars on the left sidebar.
    Then you can sign out of iCloud on the iCloud control panel and your local copies will still be there.  If you want to add your iCloud email account back to iCloud, you can do this with these settings: http://support.apple.com/kb/HT4864.

  • If someone has wiped my ipad and changed passwords on icloud how do i get my data back

    if someone has wiped my ipad and changed passwords on icloud how do i get my data back? please could someone help me out thanks

    How did they wipe it?  By using Find My iPad and performing a wipe?  If so, that means they have your icloud ID and password, not a good thing.
    You could try connecting it to iTunes and performing a restore from iCloud.  But if they changed password, then you are out of the loop.  How did they get your password in order to change it?

  • IOS 8 upgrade gone wrong - how do I get my data back?

    I was upgrading my iPhone 5S to iOS 8 today using iTunes. Halfway through iTunes through an "unknown" error and recovered my phone back to the factory settings. I don't have any backups on either iTunes or iCloud (don't ask why).
    I did a search for data recovery tools and it seems there are many out there that claim can get data back. Has anyone used any of these data recovery tools. Can they recover data in this situation?
    I have lots of contacts, Messages and Notes which are gone forever if I can't recover them.
    Many thanks.

    If your phone is back to factory condition, there's nothing to recover.
    I won't ask why you didn't make a backup before upgrading as you requested.  Doesn't mean I'm not baffled. 

  • I backed up my ipod. I then updated it but all of my data is still gone. How do I get my data back??

    I backed up my ipod. I then updated it but all of my data is still gone. How do I get my data back??

    Were the app in your iTunes library? If not the app data in the backup has no place to go. Redownload the apps in your iTunes libaray
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    and then restore from backup.
    iOS: How to back up and restore your content
    Otherwise, try restoring from backup again.
    If still problem that means the backup does not include the data.

  • I just got  new screen put on my 13in macbook pro when i opend it up there is no data on it? how do i get my data back

    I just got to school after getting a new screen put on my 13in macbook pro. when i opend up my macbook there was only a apple simble and the loading sing with a bar at the botton it took fovere to load, one it loaded and opend up there was a few options to pic from saying i could get all my datata back, i got confused and called the tec support where they wanted me to spend 90$ to back up my data, i feel as if they fixed my screen my data should be there when i go on it. I am a broke colage studend and need to get my work done. To sum it all up How do i get all my data back that happend to get lost while my screen was being repaird at the apple store?

    Apple has a 90 warranty warranty on all of their repairs.  You should take your computer back to the repair shop.  Or call Apple Customer Relations (800) 767-2775.  Wait for a human to come on the line and ask politely and firmly that you want to be transferred over to the Customer Relations department.  Tell them your issue.
    pakoning wrote:
    I am a broke colage studend
    Hard to believe with all the typos in your post!

  • How do i get my data back if i restored my ipod touch

    how do i get my data back if i restored my ipod touch

    The backup that iTunes makes does not include synced media like apps and music.
    Redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store         
    and then restore from the same backup again.

  • I deleted a calendar tab. How can I get the data back?

    I accidently deleted the calendar tab of my wife and deleted all her apoointments on her iphone and the iMac. I am in ****. How can I get the calendar data back=?

    Sync is only oneway, from PC to your device. Unless you have the music on your PC, iTunes is going to wipe out what you have on your device if you are syncing to a new library.
    You can only transfer Purchased music over to Itunes on your PC.
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer
    http://support.apple.com/kb/HT1848
    As for you own music, you may have to use a third party software. A good Free one is called Sharepod which you can download from Download.com here:
    http://download.cnet.com/SharePod/3000-2141_4-10794489.html?tag=mncol;2

  • My battery died and then when i charged the phone it is asking me to connect to itunes and restore. if i restore how can i get my data back

    My iphone battery died and on charging the phone it asked me to connect to itunes and restore the phone.
    If i restore the phone how can i get my data back and how can i check when i last backed up my phone

    If you have been syncing regularly as the iphone is designed, then you can sync the data back.
    Regardless you will have to restore the iphone.

  • I've succesful login in old sync, but nothing synching,New Sync says unknown account on Login. How can i get my data back?

    Actually I couldn't use internet for approx 1 year. I thought My every detail is safe on FF server Now. when I am trying to sync my details in old sync, in first few attempt it can't login, but eventually it successfully logs in. but nothing is synching. So tried the same thing in New Synch. but When I try to login with same details It says unknown account. So I thought making new account with same id would overwrite data with new one. so I didn't. If there is any way I can get my data back, atleast some of it. As its quite important.

    It's "safe" when you use it as intended, for synchronizing Firefox data between multiple devices. Sync was not intended to be used as you tried to use it; as a backup medium or "cloud".

  • I have synced my ipad with my computer then downloaded latest ios version.  How do I resync my data back to my ipad?

    I have synced my ipad with my computer then downloaded latest ios version.  How do I resync my data back to my ipad?

    You Restore from iTune Backup.The syncing is towards the end of the Restore.
    1. Settings>General>Reset>Erase all content and settings
    2. You'll be asked twice to confirm
    3. You'll see Apple logo and progress bar
    4. You'll see a big iPad logo on screen
    5. Configuration start
    6. Set language
    7. Set country
    8. Select Network and input Password>Join
    9. Enable Location Service>Next
    10. You'll be given 3 options (a) Setup as New iPad (b) Restore from iCloud Backup (c) Restore from iTune Backup
    11. Select Restore from iTune Backup
    12. You will see picture of USB cable pointing towards iPad
    13. Connect iPad to iTune (make sure iTune is on standby)
    14. Tap Continue (computer)
    15. Restore iPad from Backup (computer)
    16. See progress bar with estimated time (computer)
    17. See Restore in Progress on iPad
    18. See Apple logo
    19. See Apple and Progress Bar
    20. Slide to Unlock
    21. Copying Apps back to iPad (computer)
    22. You'll see Loading/Installing/Waiting below the Apps (iPad)
    23. Sync Music/Podcast/Movies to iPad (computer)
    24. Sync completed (computer)

  • I lost my iPhone device, how can I get my data back on another one without using an iCloud backup just back up on i Tunes, Please Help.

    I lost my iPhone device, how can I get my data back on another one without using an iCloud backup just back up on i Tunes, Please Help.??

    You can find the backup files and then copy them to a safe place if you are worrying about this.
    iTunes places the backup files in these places:
    Mac: ~/Library/Application Support/MobileSync/Backup/
    The "~" represents your Home folder. If you don't see Library in your Home folder, hold Option and click the Go menu.
    Windows Vista, Windows 7, and Windows 8: \Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\
    To quickly access the AppData folder, click Start. In the search bar, type %appdata%, then press Return.
    Windows XP: \Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
    To quickly access the Application Data folder, click Start, then choose Run. In the search bar, type %appdata%, then click OK.

Maybe you are looking for

  • Record Selection doesn't work with VS 2005 & CR 2008

    Hi all, Recently I installed CR 2008 with Service Pack 1 and integrate with Visual Studio 2005. I converted all the CR reports to CR 2008 while opening the VS project which was created earlier. My problem is when I load the Crystal report via created

  • Mac Mini - Running Final Cut Express - Output to a 2nd display

    Anyway of using Final cut Express to output to a 2nd display on a Mac Mini. I know out of the box it only supports either vga or dvi (1 monitor). What does final cut express require for this option to work? A 2nd video card? Thanks

  • Optional Parameter - Oracle Package Throws an Error

    Hi there, I have an Oracle Package & it has a stored procedure with optional parameter. The calling code is in ColdFusion. When I run my webpage the Oracle throws below error. " [Macromedia][Oracle JDBC Driver][Oracle]ORA-06550: line 1, column 7: PLS

  • Currency: MXP to USD how to convert ?

    Hi everybody, I´m junior, I have a question, I need to convert currency MXP to USD, I need to know what is the actual value of dollar, I know that the system have the value but I couldn´t find it. Can anybody tell me How can I know it? Thanks,

  • 802.1x RADIUS with EAP-TLS/EAP-TTLS & Dynamic VLAN Assignment

    Hello, My team is looking for switches supporting 802.1x authentication on either EAP-TTLS or EAP-TLS protocols with dynamic vlan assignment enabled for these. Looking at the data sheets of the Linksys desktop switches, I found only SLM224G4PS and SL