Storing data in  tablemodel to a binary  file

hi,
i have a program that uses AbstractTableModel with Jtable....I need to store data in a file when the program closes... i heard that there is a way to some how convert data in Tablemodel to a binary file and retrieve data from the binary file...other then storing it in a text file and parsing the data. So can anyone help me?
Thanks

You can loop through the data in the table and Serialize the data using object serialization.
Simply implement the java.io.Serializable interface. Then use this code for serizlizing the data. Note that to serialize data, it must be an object not primitive types.
serialize to a binary file
try
    ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(new File("datastore.ser")));
    os.writeObject(<your data from table>);
    os.flush();
catch (IOException ioe) { ioe.printStackTrace(); }
reconstructing the object from binary file
try
    ObjectInputStream is = new ObjectInputStream(new FileInputStream(new File("datastore.ser")));
    obj = (<data type of Object>) is.readObject();
catch (IOException ioe)
    ioe.printStackTrace();
}Hope this helps,
Riz

Similar Messages

  • When I try to download a software up date for another program in Binary File (eg CCleaner or a Microsoft file) in FireFox they all just come up in the download window as 'Cancelled'? When I go to the destination folder the download file icon is there wit

    When I try to download a software up date for another program in Binary File (eg. C Cleaner or a Microsoft file) in Firefox they all just come up in the download window as 'Canceled'? When I go to the destination folder the download file icon is there with 0 Kb's for size...Then when I click 'RETRY' the download it appears to download fully, but when I go into the destination folder the downloaded file is not there? I need to know if there is something in the Firefox options to resolve this problem or much more!!

    If all .exe files are blocked, antivirus software is most likely configured to block them. See if you can download these with your antivirus and/or security software disabled.

  • How to write a Data Plugin to access a binary file

    hi
    Im a newbee to DIAdem, i want to develop a data plugin to access a binary file with any number of channels.For example if there around 70 channels, the raw data would in x number of files which will contain may be around 20 channels in each file . Raw file consist of header(one per file), channel sub header(one per channel),Calibration Data Segment(unprocessed datas) and Test data segments(processed data)....
    Each of these contains many different fields under them and their size varies ....
    Could suggest me some procedure to carry out this task taking into consideration of any number of channels and any number of fields under them....
    Expecting your response....
    Jhon

    Jhon,
    I am working on a collection of useful examples and hints for DataPlugin development. This document and the DataPlugin examples are still in a early draft phase. Still I thought it could be helpful for you to look at it.
    I have added an example file format which is similar to what you described. It's referred to as Example_1. Let me know whether this is helpful ...
    Andreas
    Attachments:
    Example_1.zip ‏153 KB

  • Multipart/form-data using HTTPService, sending a binary file and some text in the same request.

    Hi There,
             I am new to FLEX and also new to writing a client for a web service.
    My question is more about flex (Flash builder 4.5) APIs, what APIs to use.
    I want to access a web service, that's published here.
    https://build.phonegap.com/docs/write_api
    here is the description of webservice
    ===========
    1) I have to do a post on POST https://build.phonegap.com/api/v1/apps
    2) content type has to be "multipart/form-data"
    3) JSON bodies of requests are expected to have the name 'data'
      data will be someting like this
    'data={"title":"API V1 App","package":"com.alunny.apiv1","version":"0.1.0","create_method":"file"}'
    4) include a zip file in the multipart body of your post, with the parameter name 'file'.
    ===========
    I want to make a 'multipart/form-data' Post and send
    one string and one zip file.
    My first question to self was If i send both string + binary data in the body ...
    how will server understand where string end and where zip file starts?
    Then read on W3.org( http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2 )
    How is text + binary data can be sent through "multipart/form-data" post requst.
    there has to be some boundries.
    After this I read and example in flex and  tried following it.
    http://codeio.wordpress.com/2010/04/03/5-minutes-on-adobe-flex-mimic-file-upload-for-in-me mory-contents/
    but it doesn't seems to be working for me.
                        public function createNewApp(cb:Function , appFile : File):void
                                  var service:HTTPService = new HTTPService();
                                  service.url = ROOT+"apps";
                                  service.showBusyCursor = true;
                                  service.addEventListener(ResultEvent.RESULT, function(e:ResultEvent):void {
                                            //translate JSON
                                            trace(e.result);
                                            var result:String = e.result.toString();
                                            var data:Object = JSON.parse(result);
                                            cb(data.link);
                                  service.addEventListener(FaultEvent.FAULT, defaultFaultHandler); //todo : allow user to add his own as well
                                  authAndUploadNewApp(service,appFile);
                        private function authAndUploadNewApp(service:HTTPService,appFile : File):void {
                                  var encoder:Base64Encoder = new Base64Encoder();
                                  encoder.encode(username + ":"+password);
                                  service.headers = {Accept:"application/json", Authorization:"Basic " + encoder.toString()};
                                  service.method ="POST";
                                  var boundary:String = UIDUtil.createUID();
                                  service.contentType = "multipart/form-data; boundary=—————————" + boundary;
                                  var stream:FileStream = new FileStream();
                                  stream.open(appFile, FileMode.READ);
                                  var binaryData:ByteArray = new ByteArray();
                                  var fileData : String = new String();
                                  stream.readBytes(binaryData);
                                  stream.close();
                                  fileData = binaryData.readUTFBytes(binaryData.bytesAvailable); // I think this is where I have problem.... how do
                           //how do i converrt this bytearray/stream of data to string and send it in my post request's body - i guess if this step work rest should work..  
                                  var params: String = new String();
                                  var content:String = "—————————" + boundary + "nr";
                                  content += 'Content-Disposition: form-data; name="data";' + '{"title":"ELS test app 2","package":"com.elsapp.captivate","version":"12.3.09","create_method":"file"}' + "nr";
                                  content += "—————————" + boundary + "nr";
                                  content += 'Content-Disposition: form-data; name="file";' + fileData  + "nr";
                                  content += "—————————–" + boundary + "–nr";
                                  service.request = content;
                                  service.send();

    In the past I have used URLVariables with URLRequest and URLLoader to achieve this kind of requirement.
    Check out http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_3 .html which should be useful. My preference has always been to use this style instead of HTTPService objects, giving you a little more control which is what you need here.
    Let me know if you need any more assistance.

  • Storing data in AbstractTableModel

    hi,
    i have a program that uses AbstractTableModel with Jtable....I need to store data in a file when the program closes... i heard that there is a way to some how convert data in Tablemodel to a binary file and retrieve data from the binary file...other then storing it in a text file and parsing the data. So can anyone help me?
    Thanks

    Hi missKip,
    As far as I know, class "javax.swing.table.AbstractTableModel" is abstract, so your "JTable" must be using a class that extends "AbstractTableModel".
    In any case, writing and reading from a file -- with java -- has nothing to do with "JTable"s and/or "AbstractTableModel"s -- it has to do with the classes in package "java.io". Are you not familiar with these classes or how to use them?
    Unfortunately, based on the [lack of] information you have provided, I cannot give you any details on the sort of code you need to write, I can only point you at resources (that I assume you are unfamiliar with) that may help you:
    http://java.sun.com/docs/books/tutorial/essential/io/index.html
    http://developer.java.sun.com/developer/technicalArticles/Streams/
    http://www.oreilly.com/catalog/javaio/
    Hope this helps you.
    Good Luck,
    Avi.

  • Binary file data plugin : append block values to channel

    I need to create a data plugin for a unique binary file structure, which you can see in the attached graphic.
    With these objects
    Dim sBlock : Set sBlock = sFile.GetBinaryBlock()
    sBlock.Position = ? 'value in bytes
    sBlock.BlockWidth = ? 'value in bytes
    sBlock.BlockLength = ? 'value in bits
    I have the possiblity to read chunks from my binary file. At the end, I want to have each signal in a respective channel. I could manage to extract signals 1 and 2, as they only have one value in each block with a known byte-distance in between. How can I extract the other channels, that have 480 successive values in each block? I could probably write a loop and read the specific signal part in each block, but how can I append these parts to the relevant channels? I tried by creating a new channel and then merging them, but unfortunately functions like ChnConcat are not working in a data plugin. Any ideas?
    /Phex
    PS. Of course I could create a hideous plugin with running GetNextBinaryValue() throught the whole file, but that doesn't seem to be a smart idea for a 2 GB file size.
    Attachments:
    KRE_DataPlugin_schematic.JPG ‏84 KB

    Phex wrote:
    @usac:
    Your workaround seems to work at least for part of the file. If I loop it through the whole 1.5 GB file I am getting the DLL error "The application is out of memory". There is enough dedicated RAM available, but I guess this is x86 related.
    Hello Phex,
    Have you tried running this Script in the DIAdem 64-bit preview version (which gets you access to more than 2 GB or RAM for your application) that can be found at http://www.ni.com/beta and can be installed in parallel to the 32-bit version.
    It might get you around the "out of memory" issue ...
          Otmar
    Otmar D. Foehner
    Business Development Manager
    DIAdem and Test Data Management
    National Instruments
    Austin, TX - USA
    "For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."

  • Streaming data from cRIO to a data file (binary file) on a network Network Drive on the same LAN

    Dear All 
    I hope my message finds you all well 
    My Question is :  is it possible to log my data from cRIO to a network drive and stream the data being captured to a binary file in this drive ? and do the conventional File IO functions ?
    I heard that DataSocket can do this , but it is mainly used between computers (this is what i understood so far about it)
    My network drive is a DLink ShareCenter : http://sharecenter.dlink.com/products/DNS-320
    I know that i can use the NI 9802 SD Card module , but it is out of my budget now to buy it 
    Please assist 
    Best Regards
    Eng. Mohammed Ashraf
    Certified LabVIEW Associated Developer
    InnoVision Systems Founder, RF Test Development Engineer
    www.ivsystems-eg.com

    Hi Mohammed,
    Are you trying to accomplish all this with or without the use of a host machine? If you're doing it with a host machine then the best bet would be to transfer data to the host using network published shared variables and then write to a file on the network from there. 
    If you're trying to do all this from the cRIO straight to the network drive with no intermediate host PC there are many things to consider. First off would be making sure there are no security protocols on the network drive that would prevent the cRIO from accessing it. Next you'd have to make sure there are no drivers required for the network drive as many drivers will not work on the Real-Time OS since most of these drivers are designed for a Windows system. If all this is taken care of then I'd say FTP is probably your best bet for getting files onto the network drive as long as you have an FTP server. 
    I'm unsure about if you would be able to stream to a binary file from a cRIO. I would need to know more about your application and what hardware you're using. Again I'd recommend you use a host PC and do the file I/O from there if possible. Can you tell us a bit more about your application and setup?
    Miles G.
    National Instruments
    Applications Engineer

  • How to input notes in a binary file used to save continuous DAQ?

    Hello,
    I have a continuous data acquisition vi with trigger. Data is saved in a binary file. I would like to save some comments or notes in this file; I want to be able to read the notes afterwards and the saved data that has to be displayed in charts. I got some examples from NI but they are simple and do not include the continuous data acquisition and reading both the notes and the (dynamic) data.
    Does anyone have examples of binary files with notes and continuous DAQ write and read?
    I've been working on this issue for quite a while and I got stuck...
    Thanks...

    Thank you Emilie.
    I know these examples all right. Now try embedding this into a 'Cont Acq. and Chart - Int. Clk.vi' or any vi that does data acquisition and saves the data in the same file where you wrote the string of comments. And this is not all - how do you read them all back in the right order and right length...
    I have inserted some examples to make you understand better what I am talking about.
    'AcquirePFV_Header.vi' and 'Read_with Header.vi' are only some trials that do not really work correctly.
    Could you or anybody else help me solve this problem?
    Thank you.
    Radu
    Attachments:
    ForNI03.zip ‏1170 KB

  • Write output to binary file in C/C++?

    How can I write output to a file in binary format instead of ascii?
    Or... if I am using a buffer.. to write a buffer to binary format instead of ascii?
    I am writing a lot of data to a text file and I would like to reduce the size by writing it all into a binary file instead of ascii?
    Last edited by kdar (2012-12-13 14:36:41)

    Basic I/O?
    char buffer[100];
    // C++ style
    ofstream file;
    file.open ("data.bin", ios::out | ios::binary);
    file.write(buffer, sizeof buffer);
    /* C style */
    FILE* file2 = fopen("data2.bin", "wb");
    fwrite(buffer, sizeof buffer, 1, file2);
    A lot of people prefer the old C style functions for binary i/o even in C++ (and iostream for formatted i/o). Writing and readong more complex structures requires some castin, in C++ usually done with reinterpret_cast<char*>(someStructure).

  • Binary file created during db2bak

    Hello,
    I have a Sun ONE Directory Server 5.1. Every night, I excute db2bak command to save my data. This command creates binary file (log.0000001290 for example). Does anyone know what is this file ?
    Thanks.
    Delphine

    These are just transaction log files. Changes are made to these logs and then processed periodically by the directory server. You should see them increment as they get created and then processed.

  • How to read binary files wrt specific BYTE size and length??

    Hello Everyone,
                                I have a project I want to accomplish. I have a binary file, and I would like to read the data and print on wfm in a specific order and size.
    The data is 16 bit binary type , and needs to be read in chunks of 2 bytes.
    i have 30 bytes of sample 1.
    followed by 2 bytes of sample 2.
    followed by another 2 bytes of sample 3.
    steps 2-4 should be repeated 10 times and then i should read sample 4 which is of 2 bytes.....
    How should I do it?? I don't have any VI build... all i have is the example VI...
    can anyone pleasehelp me???
    Now on LabVIEW 10.0 on Win7

    smercurio_fc, sorry for the confusion, i will try my best to explain...
    1. No, i don;t have to read the file again, once it has read, I used
    while loop just to see the data updating (i press run, and before i can
    visualize i have the waveforms; i can get rid of the while loop)
    2. I have 30 different values of 1 sample. actually, the data is cmg
    from tri-axial accelerometer; each axis is of 10 bytes(hence 3*10 =
    30bytes)
    3. I am repeating the steps 2-4 10 times because the data was written
    into the binary file after 10 times sampling the sensors(if first 3
    samples are read @ 1000hz, sample 4 was read at 1000/10 = 100hz)
    4. I am using the graphs to interpret the values, that's it. The
    values are already scaled when they were wrote to the binary file, I
    have to simply interpret it.
    I have made some changes in the VI, now i am reading only the first
    30bytes, that too, in chunks of 10-10-10 bytes, and plotting the 3
    samples simultaneously on a waveform chart. (will approach 1
    sensor/sample at a time) and running the loop for 10 times. I have changed I8 to I16 now.
    Please let me know if it makes sense to you now.
    P.S. each sample is a sensor data.
    Now on LabVIEW 10.0 on Win7
    Attachments:
    data_read.vi ‏24 KB

  • Storing data in binary files

    I am trying to store my data in binary files to save space and lessen time spent on hard disk reads. However, I can't seem to find the proper way to do this in java.
    For example, I have the integer 65535 in java. How do I convert it into a 2 byte string FF FF in java?
    When I read 2 bytes FF FF to a string from a binary file, how do I interpret it as a -32767 or a 65535 ?
    Sorry if this seems like a really obvious question. None of the integer or string methods in java seems to do what I want :(

    If all you want is a compressed file, you might want to use java.util.zip.GZIPOutputStream, and send it data in a simple format (like XML) rather than trying to compress everything to bytes yourself.

  • Should heavy binary files be stored in database?

    I was asked an interesting question: Should a database contains all data? Or heavy binary files should be stored in file system?
    Example of heavy binary files : videos or heavy pdf files (+200 MB).
    With an old aspx web app (1.1) I tried to open a 200MB pdf file stored as a blob in an Oracle 11g database, and it just run out of memory.
    However, same asp.net web application had no problem to open same pdf file stored in file system of a server. It could be that maybe there is some proper way to open heavy blobs fields with asp.net.
    For integrity reasons, I say that all data should be stored in database, but my described case showed me that maybe it's not the way.
    SQL Server allows the contents of varbinary(max) columns to be stored on the file system, maybe there is something similar in Oracle?

    user521219 wrote:
    With an old aspx web app (1.1) I tried to open a 200MB pdf file stored as a blob in an Oracle 11g database, and it just run out of memory.Because it likely tried to read, and cache, the entire BLOB. Instead of reading and streaming BLOB chunks to the (web browser) client.
    However, same asp.net web application had no problem to open same pdf file stored in file system of a server. It could be that maybe there is some proper way to open heavy blobs fields with asp.net.So now blame Oracle for the inability of an ASP/.Net programmer to stream file contents correctly, but not LOB contents?
    SQL Server allows the contents of varbinary(max) columns to be stored on the file system, maybe there is something similar in Oracle?You want Oracle to be like SQL-Server? Oracle does a poor SQL-Server imitation. It plays the role of being Oracle, technically the most advance relational database management system available, excellently.

  • Problem woth storing data in binary.

    Hi,
    I have some data which I am storing in binary and when I read it back in, I get different data than that which was stored...I was wondering if anyone could help me out as to what I have done wrong,  Below are the 2 Vi's I am using to test this: the first one makes the binary file, the second one reads it back in.  Thanks a lot for any help!
    Intern NSWCCD Carderock.
    Attachments:
    Untitled.vi ‏47 KB

    The read vi is actually a bit more complex to modify.
    Modifications to "read from SGL file":
    Replace the "4" with an "8" for the quotient&remainder division (8bytes/DBL).
    Change the "1D array" and "2D array" output to DBL.
    Open "Read File +[SGL]"
    Change "to Single precision float" to "to double prescision float".
    Change the "1D data" and "2D data" arrays to DBL.
    Of course you could just use a few low level VIs instead, you probably don't need all that flexibility to read or write a plain DBL 1D array.
    LabVIEW Champion . Do more with less code and in less time .

  • How can I read a binary file stream with many data type, as with AcqKnowledge physio binary data file?

    I would like to read in and write physiological data files which were saved by BioPac�s AcqKnowledge 3.8.1 software, in conjunction with their MP150 acquisition system. To start with, I�d like to write a converter from different physiodata file format into the AcqKnowledge binary file format for version 3.5 � 3.7 (including 3.7.3). It will allow us to read different file format into an analysis package which can only read in file written by AcqKnowledge version 3.5 � 3.7 (including 3.7.3).
    I attempted to write a reader following the Application Note AS156 entitled �AcqKnowledge File Format for PC with Windows� (see http://biopac.com/AppNotes/ app156Fi
    leFormat/FileFormat.htm ). Note the link for the Mac File format is very instructive too - it is presented in a different style and might make sense to some people with C library like look (http://biopac.com/AppNotes/ app155macffmt/macff.htm).
    I guess the problem I had was that I could not manage to read all the different byte data stream with File.vi. This is easy in C but I did not get very far in LabView 7.0. Also, I was a little unsure which LabView data types correspond to int, char , short, long, double, byte, RGB and Rect. And, since it is for PC I am also assuming the data to be written as �little endian� integer, and thus I also used byte swap vi.
    Two samples *.acq binary files are attach to this post to the list. Demo.acq is for version 3.7-3.7.2, while SCR_EKGtest1b.acq was recorded and saved with AcqKnowledge 3.8.1, which version number is 41.
    I would be grateful if you someone could explain how to handle such binary file stream with LabView and send an example to i
    llustrate it.
    Many thanks in advance for your help.
    Donat-Pierre
    Attachments:
    Demo.acq ‏248 KB
    SCR_EKG_test1b.acq ‏97 KB

    The reading of double is also straight forward : just use a dble float wired to the type cast node, after inverting the string (indian conversion).
    See the attached example.
    The measure of skin thickness is based on OCT (optical coherent tomography = interferometry) : an optical fiber system send and received light emitted to/back from the skin at a few centimeter distance. A profile of skin structure is then computed from the optical signal.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Read_AK_time_info.vi.zip ‏9 KB

Maybe you are looking for

  • BW system not receiving Idocs from R/3 system

    Hi all, I am having a problem with my BW system. What happened is that we deleted logical systems in R/3 and then recreated them but now in BW we can't display received data. We checked using rsa3 extractor checker and the data is available in R/3 bu

  • 2LIS_40_REVAL

    Hi there, I'm in a Retail environment. I'm using 2LIS_03_BX, 2LIS_03_BF, 2LIS_03_UM to fill an InfoCube and have the monthly stocks. Quantities and valuation at purchase value are correct. As I want to add to my report the valuation at retail value f

  • Displaying Forwarded Messages in Messenger Express

    One of my users noted that when they forward a message that was sent to multiple recipients, the forwarded message, as displayed in Messenger Express, suppresses the display of the list of users that the original message went to. I've tested this by

  • Hex to binary removes leading or trailing 0's

    hi, i'm trying to get a hex to binary conversion.  i am using a hex string to number conversion with the setting at binary, but it is deleting my leading zeros. for example if i put in a 7 hex, i get 111 instead of 0111.  or if i put in a 0 hex, i ge

  • How to convert rich black to flat black?

    I have some cartoons that are downloaded as CMYK. The black in them is rick black, and I need it to be flat black (100% black but not grayscale). What's the best way to do this?