About XML Reading and Writting

In My project it is a DBMS using XML Schema
i want to restore the file "DataBase" and then append on it
(copy the file values onto the tree memory and continue working on it)

nifty!

Similar Messages

  • Read and write existing xml file trouble !

    Hi everyone ! 
    i'm trying to save hight score of user in my game by using a xml file , in my xml file has element <best_score>0<best_score/>
    and my code to do it is : 
     XElement best=XElement.Load("Assets/best.xml");
                IEnumerable<XElement> loc = best.Elements("best_score");
                foreach (XElement elem in loc)
                    int check=Convert.ToInt32(elem.Value.ToString());
                    int score_user = Convert.ToInt32(scores.ToString());
                    if (score_user >= check)
                       hight_score.Text = score.ToString();
                         elem.Value = scores.ToString();
                         // what code to save this  xml file  after modify ?????
                    else
                        list_box.Text = check.ToString();
    i down know what method can help me save my xml file after update hight score of user in this case .  
    Anyone has an idea to solve it for me ? please , thanks you ! 
    sorry about my english ! 

    Hi,
    It is not recommended to update a file withing the project, so you need to store it in the IsolatedStorage.
    Here is a sample to read and write file in IsolatedStorage,
    XDocument xDoc;
    var file = Util.ReadFile("XMLFile.xml");
    if (file != null)
    xDoc = XDocument.Parse(file);
    var bestScore = xDoc.Element("best_score").Value;
    //do calculation
    xDoc.Element("best_score").Value = "200";
    Util.SaveFile("XMLFile.xml", xDoc.ToString());
    For the above code to work, you need to have a file named "XMLFile.xml" in your IsolatedStorage, with data as  "<best_scrore>200</best_scrore>"
    To read and write file:
    public static class Util
    public static void SaveFile(string filename, string data)
    try
    using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
    using (var stream = new IsolatedStorageFileStream(filename, FileMode.Create, FileAccess.ReadWrite, store))
    StreamWriter writer = new StreamWriter(stream);
    writer.Write(data);
    writer.Close();
    catch (Exception)
    Debug.WriteLine("Couldn't save the file.");
    public static string ReadFile(string filename)
    try
    String data;
    if (!IsolatedStorageFile.GetUserStoreForApplication().FileExists(filename)) return null;
    using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
    using (var stream = new IsolatedStorageFileStream(filename, FileMode.Open, FileAccess.ReadWrite, store))
    StreamReader stmReader = new StreamReader(stream);
    data = stmReader.ReadToEnd();
    stmReader.Close();
    return data;
    catch (Exception)
    return null;
    Pradeep AJ

  • Reading an XML file and write the contents to another xml file in java

    Hi,
    I am new to xml parsing.My requirement is that I am getting a message (xml) using ibm MQ in the ByteArrayInputStream format.I have to read this xml message and write to another file.
    I am creating a POC for this.
    First I used simple reading and writing concept but the output is "java.io.FileInputStream@3e25a5 "
    Sample xml file
    - <Client>
    <ClientId>1234</ClientId>
    <ClientName>STechnology</ClientName>
    <DTU_ID>567</DTU_ID>
    <ClientStatus>ACTIVE</ClientStatus>
    - <LEAccount>
    <ClientLE>678989</ClientLE>
    <LEId>56743</LEId>
    - <Account>
    <AccountNumber>9876543678</AccountNumber>
    </Account>
    </LEAccount>
    - <Service>
    <Cindicator>Y2Y</Cindicator>
    <PrefCode>980</PrefCode>
    <BSCode>876</BSCode>
    <MandatoryContent>MSP</MandatoryContent>
    </Service>
    </Client>
    code:
    import java.io.ByteArrayInputStream;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    public class ByteArrayInputStreamToXml {
         public static void main(String srg[]) throws IOException{
              InputStream inputStream= new FileInputStream("C:\\soft\\test2\\sample1.xml");
              byte currentXMLBytes[] = inputStream.toString().getBytes();
              ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(currentXMLBytes);
              OutputStream out = new FileOutputStream("C:\\soft\\test\\data.xml");
              int read=0;
              byte[] bytes = new byte[1024];
              while((read = byteArrayInputStream.read(bytes))!= -1){
              out.write(bytes, 0, read);
              out.write( '\n' );
              inputStream.close();
              out.flush();
              out.close();
              System.out.println("New file created!");
    Please suggest me how can I use DOM/SAX parser ,I can see several code on net for reading xml file using SAX/DOM parser but writing an xml file after reading it using ByteArrayInputStream I am not getting .A help through some example Link will also be helpful for me.
    Thanks
    Sumit
    Edited by: user8687839 on Apr 30, 2012 2:37 AM
    Edited by: user8687839 on Apr 30, 2012 2:43 AM

    Thanks I got the result.
    package com.sumit.collections;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    public class ByteArrayInputStreamToXml {
         public static void main(String srg[]) throws IOException{
              InputStream inputStream= new FileInputStream("C:\\soft\\test2\\sample1.xml");
              ByteArrayOutputStream buffer = new ByteArrayOutputStream();
              int nRead; byte[] data = new byte[1024];
              while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
              buffer.write(data, 0, nRead); } buffer.flush();
              byte currentXMLBytes[]= buffer.toByteArray();
              /* byte currentXMLBytes[] = inputStream.toString().getBytes();*/
              ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(currentXMLBytes);
              OutputStream out = new FileOutputStream("C:\\soft\\test\\data.xml");
              int read=0;
              byte[] bytes = new byte[1024];
              while((read = byteArrayInputStream.read(bytes))!= -1){
              out.write(bytes, 0, read);
              out.write( '\n' );
              inputStream.close();
              out.flush();
              out.close();
              System.out.println("New file created!");
    }

  • How to Read and Write .XML datas   (HELP Plz...)

    hai everybody
    how to read and write xml datas... plz give clean and simple example..
    bcoz me want to produce such type of module...
    if any one help me .. thats the only way me laid in software ladder
    plz....
    thank u in advance

    thank u for giving idiot..
    but before posting i search in google also..
    but i cant get what me expect..
    thus i posted...
    then who is ................?
    sorry javacoder01
    // plz help me
    Message was edited by:
    drvijayy2k2

  • Create xml file and write data in to it:

    Hi All,
    I have a small requirement here.....
    I have a java program which reads a xml file.
    Now i have stored the contents of that file in to a java object.
    I want a sample code now which would take theabove mentioned java object as an input ,create a xml file and write these entries in to the file.
    Can anyone help me in this?
    Your help would be appreciated.
    Thanks in advance.
    vrkr

    Hmmm. There is nothing special about an XML file to any other file. The data is simply formatted in a certain way. So to write an XML file, it is no different to writing any other form of file in Java (assuming you know the structure of the xml format to write - which you should)
    If you don't know how to write files using Java I would suggest using the Java Tutorial found on java.sun.com and do some reading up about I/O since this is fairly fundamental.
    http://java.sun.com/docs/books/tutorial/
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • Plugin-container and Flashplugin are both generating a million reads and writes an hour... even when Firefox is minimized and running no audio/video; how can I

    I am running FF 18.0.2 on a Win7 system with an i7 CPU and 8GB RAM. My Flash plugin is newly-updated. I've used Firefox on this machine its entire life (3 years).
    Since 3 or 4 (?) versions ago, I've been getting massive activity on my hard drive with Firefox. When I check with Win Task Manager, I see the plugin-container.exe *32 and the FlashPlayerPlugin_11_5_502_149.exe *32 processes are generating millions of I/O reads and writes, even while Firefox is idle (minimized, running no audio or video). On this latest version, 18.0.2, the drive activity stalls out YouTube videos repeatedly, even though I can see they're buffered ahead. The playing video will stop, audio will continue to end of buffer, and then EVERYTHING stops (Firefox not responding) for 30 seconds or so. It will then pickup again and play until it repeats the same pattern in a minute or so.
    Example: I closed and restarted Firefox 2 days ago. Earlier today I checked Windows Task Manager and found the two processes EACH generated about 161 million reads and 141 million writes since then! My wife's laptop is showing nothing like a hundredth of that.
    The constant drive activity is slowing down all programs outside of Firefox too, as you might imagine. The PC is acting like it's a dedicated machine for Flash.

    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • I cannot update from OS 10.9.4 to 10.9.5. I get a message saying: File couldn't be installed error (513). I have configured my OS so that I have read and write permission followed by system with read and writ permission. Can someone help me? Thanks.

    I cannot update from OS X 10.9.4 t0 10.9.5> Whenever I try I get the following message: File couldn't be installed error (513) and something about not having the proper permission.  Under the Macintosh HD sharing and permissions settings I have customized the settings so that (Me) has read and write permission followed by the system with read and write permission, wheel and everyone have Read permissions.
    I have no problems updating apps such as Adobe CC or iTunes but cannot update the operating system, can someone help me? Thanks.

    1. Restart the computer in safe mode. Certain caches maintained by the system will be rebuilt.
    Safe mode is much slower to start up than normal. The next normal startup may also be somewhat slow.
    When the login screen appears, restart as usual (not in safe mode) and test. There's no need to log in while in safe mode.
    Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a software RAID, you can’t start in safe mode. In that case, go to Step 2.
    If there's no change after taking this step, continue.
    2. Back up all data before proceeding.
    Triple-click anywhere in the line below on this page to select it:
    /var/folders
    Right-click or control-click the highlighted line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item named "folders" selected. Move the selected item to the Trash. You may be prompted for your administrator login password. Restart the computer and empty the Trash.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • Read and Write data in iphone app

    I want to build a simple offline mobile app which reads and writes or stores info to a file, xml, json, txt or whatever.
    What is the best way to do this?
    I am currently learing jQuery and PHP, so I don't want to have to learn some other million things that does one thing but not another.
    Can this be achived without objective C? Can i do this with Jquery and phone Gap?
    Thanks

    Do a search for 'HTML 5 Storage' and you'll find a bunch of resources that will help. Here's a few
    http://www.w3schools.com/HTML/html5_webstorage.asp
    http://diveintohtml5.info/storage.html
    http://htmlpad.wordpress.com/2010/03/10/html-5-data-storage-javascript-api-on-ipad-and-iph one/

  • Can you improve the speed of my CSV Reader and Writer?

    hi all, i'm trying to develop a CSV Writer and Reader. i have done a good work to implement the special character and quoting it, it's also support multi line value but it's incredibly slow.
    can someone help to make it faster?
    here it's how to use the writer
    char *stringhe_sorgenti[10] = {0};
    out = OpenFile(nfile, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII);
    for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
    stringhe_sorgenti[i] = (char*)calloc(200, sizeof(char));
    sprintf(stringhe_sorgenti[0], "example1");
    sprintf(stringhe_sorgenti[1], "example2");
    scrivi_riga_csv(out, stringhe_sorgenti, sizeof(stringhe_sorgenti)/sizeof(char*), formato);
    for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
    free(stringhe_sorgenti[i]);
    CloseFile(out);
    here is the writer 
    void scrivi_riga_csv(int file_handle, char *stringa_sorgente[], int numero_stringhe, int formato)
    char delimitatore[2][2] = {{',', '\0'}, {';', '\0'}};
    char stringa_destinazione[1024] = {0};
    int index_destinazione = {0};
    int index_start = {0};
    int index_fine = {0};
    int errore = {0};
    int i = {0};
    //int k = {0};
    size_t lunghezza_stringa = {0};
    for(i = 0; i < numero_stringhe; i++){
    if(i != 0){
    stringa_destinazione[index_destinazione++] = delimitatore[formato][0];
    index_start = 0;
    lunghezza_stringa = strlen(stringa_sorgente[i]);
    // se la stringa sorgente
    if( (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, delimitatore[formato], 0, 0) != -1) // contiene delimitatore
    || (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, "\"", 0, 0) != -1) // contiene parentesi
    || (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, "\n", 0, 0) != -1) // contiene a capo
    // apro parentesi all'inizio
    stringa_destinazione[index_destinazione++] = '"';
    // metodo find pattern, piu' complesso ma piu' performante
    do{ index_fine = FindPattern(stringa_sorgente[i], index_start, lunghezza_stringa - index_start, "\"", 0, 0);
    if(index_fine != -1){
    index_fine++;
    // copio dall'inizio fino alle virgolette
    CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], index_start, index_fine - index_start);
    index_destinazione += index_fine - index_start;
    // ne aggiungo una dopo
    stringa_destinazione[index_destinazione++] = '"';
    // aggiorno la posizione di start e riparto con il while
    index_start = index_fine;
    }while(index_fine != -1);
    CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], index_start, lunghezza_stringa - index_start);
    index_destinazione += strlen(stringa_sorgente[i]) - index_start;
    // alla fine della riga chiudo la parentesi
    stringa_destinazione[index_destinazione++] = '"';
    else{
    // altrimenti la copio semplicemente e shifto l'indice della stringa di destinazione
    CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], 0, lunghezza_stringa);
    index_destinazione += strlen(stringa_sorgente[i]);
    memset(stringa_sorgente[i], 0, strlen(stringa_sorgente[i]));
    errore = WriteLine (file_handle, stringa_destinazione, strlen(stringa_destinazione));
    if(errore == -1){
    errore = GetFmtIOError();
    MessagePopup("WriteLine -> WriteLine", GetFmtIOErrorString(errore));
    return;
     here how to read the file
    char *stringhe_sorgenti[10] = {0};
    for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
    stringhe_sorgenti[i] = (char*)calloc(200, sizeof(char));
    out = OpenFile(nomearchivio, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_BINARY);
    leggi_riga_csv(out, stringhe_sorgenti, sizeof(stringhe_sorgenti)/sizeof(char*), formato);
    strcpy(intestazione.data, stringhe_sorgenti[1]);
    for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
    free(stringhe_sorgenti[i]);
    CloseFile(out);
     and here the reader
    void leggi_riga_csv(int file_handle, char *stringa_destinazione[], int numero_stringhe, int formato)
    char delimitatore[2][2] = {{',', '\0'},
    {';', '\0'}};
    char stringa_sorgente[1024] = {0};
    int stringa_in_corso = {0};
    int index_inizio_valore = {0};
    int index_doublequote = {0};
    int offset_stringa_destinazione = {0};
    size_t lunghezza_stringa = {0};
    int inquote = {0};
    int errore = {0};
    int i = {0};
    for(i = 0; i < numero_stringhe; i++){
    lunghezza_stringa = strlen(stringa_destinazione[i]);
    memset(stringa_destinazione[i], 0, lunghezza_stringa);
    do{ memset(&stringa_sorgente, 0, sizeof(stringa_sorgente));
    errore = ReadLine(file_handle, stringa_sorgente, sizeof(stringa_sorgente) - 1);
    // If ReadLine reads no bytes because it has already reached the end of the file, it returns –2.
    // If an I/O error occurs, possibly because of a bad file handle, ReadLine returns –1.
    // You can use GetFmtIOError to get more information about the type of error that occurred.
    // A value of 0 indicates that ReadLine read an empty line.
    if(errore == -1){
    errore = GetFmtIOError();
    MessagePopup("leggi_riga_csv -> ReadLine", GetFmtIOErrorString(errore));
    return;
    else if(errore == -2){
    errore = GetFmtIOError();
    MessagePopup("leggi_riga_csv -> ReadLine", "already reached the end of the file");
    return;
    else{
    lunghezza_stringa = errore;
    index_inizio_valore = 0;
    // metodo find pattern, piu' complesso ma piu' performante
    for(i = 0; i <= lunghezza_stringa; i++){
    // se come primo carattere ho una " allora e' una stringa speciale
    if(inquote == 0){
    if(stringa_sorgente[i] == '\"'){
    inquote = 1;
    index_inizio_valore = ++i;
    else{
    // altrimenti cerco il delimitatore senza il ciclo for
    i = FindPattern(stringa_sorgente, i, lunghezza_stringa - index_inizio_valore, delimitatore[formato], 0, 0);
    if(i == -1){
    // se non lo trovo ho finito la riga
    i = lunghezza_stringa;
    if(stringa_sorgente[i - 1] == '\r'){
    i--;
    if(stringa_in_corso < numero_stringhe){
    CopyString (stringa_destinazione[stringa_in_corso], 0, stringa_sorgente, index_inizio_valore, i - index_inizio_valore);
    offset_stringa_destinazione = 0;
    stringa_in_corso++;
    if(stringa_sorgente[i] == '\r'){
    i++;
    index_inizio_valore = i + 1;
    if(inquote == 1){
    // se sono nelle parentesi cerco le virgolette
    i = 1 + FindPattern(stringa_sorgente, i, lunghezza_stringa - index_inizio_valore, "\"", 0, 0);
    if(i == 0){
    if(stringa_sorgente[lunghezza_stringa - 1] == '\r'){
    lunghezza_stringa--;
    // se non le trovo ho finito la riga, esco dal ciclo for
    break;
    // se incontro una doppia parentesi salto avanti
    else if(stringa_sorgente[i] == '\"'){
    continue;
    // !!!! fondamentale non cambiare l'ordine di questi else if !!!!!
    // se incontro una parentesi seguita dal delimitatore
    // o se incontro una parentesi seguita dal terminatore
    // \r = CR = 0x0D = 13
    // \n = LF = 0x0A = 10
    // a capo = CR + LF
    else if( (stringa_sorgente[i] == delimitatore[formato][0])
    || (stringa_sorgente[i] == '\r')
    || (stringa_sorgente[i] == '\0')
    // salvo il valore
    inquote = 0;
    if(stringa_in_corso < numero_stringhe){
    CopyString (stringa_destinazione[stringa_in_corso], offset_stringa_destinazione, stringa_sorgente, index_inizio_valore, i - 1 - index_inizio_valore);
    offset_stringa_destinazione = 0;
    stringa_in_corso++;
    if(stringa_sorgente[i] == '\r'){
    i++;
    index_inizio_valore = i;
    // se sono andato a capo scrivo fino a dove sono e poi procedo con la nuova riga
    if(inquote){
    if(stringa_in_corso < numero_stringhe){
    CopyString (stringa_destinazione[stringa_in_corso], offset_stringa_destinazione, stringa_sorgente, index_inizio_valore, lunghezza_stringa - index_inizio_valore);
    strcat(stringa_destinazione[stringa_in_corso], "\n");
    offset_stringa_destinazione += lunghezza_stringa - index_inizio_valore;
    offset_stringa_destinazione++;
    }while(inquote == 1);
    // elimino le doppie parentesi
    for(i = 0; i < numero_stringhe; i++){
    index_doublequote = 0;
    do{ lunghezza_stringa = strlen(stringa_destinazione[i]);
    index_doublequote = FindPattern(stringa_destinazione[i], index_doublequote, lunghezza_stringa - index_doublequote, "\"\"", 0, 0); // contiene doppia parentesi
    if(index_doublequote != -1){
    index_doublequote++;
    memmove (stringa_destinazione[i] + index_doublequote, stringa_destinazione[i] + index_doublequote + 1, lunghezza_stringa - index_doublequote);
    }while(index_doublequote != -1);
    return;

    the format is CSV, i try to explain better what i'm doing.
    our client asked to save acquisition data with header description in an excel readable format, i've decided to use .CSV and not .TDM because it's a simple txt file and we never used .TMD but i will propose to use it.
    after some research on the internet i've found nothing to handle .CSV in CVI except from this csv_parse but i've found it difficult to be maintained so i've write it by my own hand.
    i've written two example of how to use my function to read or write and i've copyed my function used to read and write.
    in the write function i check with FindPattern if the string to be write contain some special character, if i find this i have to quote the string to respect the standard RFC4180 and if i find a quote i have to double it. aftere i've done this check i write the line in the file.
    in the read function, that is more complicated, i:
    check if the first character is a quote.
    if it's not i copy the string until the delimitier or until the end of the line.
    if it is i have a string with special character inside so:
    i find the first quote in the string. when i've found i check if it's follwed by another quote. this means that in the starting message i was writing a single quote.
    if it's not followed by another quote but it's followed by a delimiter or a carriage return i've finished the special line.
    if i don't find it it means that the special quote have a carriage return inside and i have to check the next line. before checking the next line i save this in my string.
    after this loop i check in every string if i have a double quote and i delete one.
    the main problem is in the speed of this, i'm acquiring data at 1000 S/s with 8 active channel for 60 second so i have 480000 data to be stored, divided in 60.000 row and 8 column. to read a file like that my pc stay "locked" for 15 second or more.
    i've tried to use the arraytofile function and it's extremly fast and i can also put header because the function can start from the last position in the file but the filetoarray function start from the beginning and i cannot read the header correctly. also if i'm using the european CSV with semicolon as delimiter with arraytofile i cannot select the semicolon but only the coma

  • Read and write from access

    I am arun, a beginner in the field of LabVIEW. Now I am trying to read and write data from MS Access with out database connection toolset. How this possible. How I can use activex in Labview for doing this. Please give me some reference materials.

    Hi Arun,
    The following discussion forum talks about the same issue, and provides a good explanation and references for the different options. Also, which version of LabVIEW are you using?
    How to read/write from Access database
    Thanks,
    Lesley Y.

  • How to increase disk read and write speed after installing new SSD (2009 Macbook Pro)? Why not as fast as advertised?

    Hi everyone,
    I just installed a Crucial MX10512 GB SSD into my 2009 Macbook Pro. It's definitely much faster, but the read and write disk speed is around 200 Mb/s for both versus the 300-500 Mb/s that the SSD advertised. Any ideas as to why? And is there anything I can do to make it faster? Before I installed it, it was between 80-90 Mb/s.
    Specs:
    - currently have about 460 of 511 GB of storage available
    - am using 2GB of memory
    - running on 10.10.2 Yosemite
    Thanks!

    nataliemint wrote:
    Drew, forgive me for being so computer-incompetent but how would I boot from another OS? And shouldn't I be checking the read speeds on my current OS (Yosemite) anyways because I want to know how the SSD is performing on the OS I use? And finally, what kind of resources would it be using that would be slowing down my SSD?
    Sorry for all the questions - I'm not a Macbook wiz by any means!
    You could make a clone of your internal OS onto an external disk. Hopefully you already have a backup of some form
    A clone is a full copy, so you can boot from it. It makes a good backup as well as being useful to test things like this.
    Carbon Copy Cloner will make one or you can use Disk Utility to 'restore' your OS from the internal disk to an external one.
    Ideally the external disk is a fast disk with a fast 'interface' like Thunderbolt, Firewire 800 or USB3. USB2 can work, but it is slow & may effect the test.
    You connect the clone, hold alt at startup & select the external disk in the 'boot manager'. When the Mac is finished booting run the speed tester.
    Maybe this one…
    https://itunes.apple.com/gb/app/blackmagic-disk-speed-test/id425264550
    Test the internal & compare to the previous tests
    A running OS will do the following on it's boot disk…
    Write/ read cache files from running apps
    Write/ read memory to disk if memory is running low
    Index new files if content is changing or being updated
    Copy files for backing up (Time Machine or any other scheduled tasks)
    Networking can also trigger read/ write on the disk too.
    You may not have much activity that effects a disk speed test, but you can't really be sure unless that disk is not being used for other tasks.
    Disk testing is an art & science in itself, see this if you want to get an idea …
    http://macperformanceguide.com/topics/topic-Storage.html
    Simply knowing that it's about twice the speed would be enough to cheer me up

  • Why are my Datasocket OPC reads and writes so slow?

    I am creating an application (in LabView 6.1) that has to interface with 15-30 OPC tags (about half and half read and write) on a KepWare OPC server. It seems like the DSC Module would be overkill, but the datasocket write VIs seem to slow the system to a halt at about 6 tags. I saw something about using the legacy datasocket connect VIs, but would I really see a large performance boost from switching?
    In the existing code we have, I have seen that even the legacy VIs (our old code uses the older VIs) sometimes grind the system to a halt or lock it up completely if it loses sight of the OPC server. Has anyone else had problems with this?

    Hi IYUS,
    What OPC Server are you using?  What methods are you using to communicate?  If you are using IAOPC, have you installed the latest patch?
    Also, this post is nearly 2 years old.  You will probably get more visibility (and more help) if you post your questions in a new thread.
    Cheers,
    Spex
    National Instruments
    To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be...

  • Help ,ImageIO exception to read and write

    Hi,
    I'm dynamically creating image files through screens utility of java(prog name:- Test_ScreenShot.java) and saving
    them in memory sequentially(pic0.jpg,pic1.jpg....etc).Simultaneously I'm accessing the saved files from another
    independent application(Prog name:- Test_Main.java) through piping(executing the application like this "Java
    Test_Screens|Java Test_Main").The application is in infinite loop.I'm using Version JDK 1.5
    I use java Image to read and write image:-
    My application was running well for days.But now I'm getting sudden exceptions.
    I got an exception while trying to save an dynamically generated image file in the local memory using the Image
    class.In brief I'm getting exactly 3 types of exceptions:-
    1)java.io.FileNotFoundException: pic5.jpg (Access is denied)
    2)"Exception in thread "main" java.lang.NullPointerException
    3)Exception in thread "main" com.sun.image.codec.jpeg.ImageFormatException: Not a JPEG file: starts with 0xff 0xd9
    Here is the code snippent I wrote:
    /* Robot robot = new Robot();
    BufferedImage image = robot.createScreenCapture(screenRect);
    // save captured image to jpg file
    ImageIO.write(image, "jpg", new File(outFileName));*/
    And here is the exception I am finding (I never found this before, I executed the code many times )
    =====================================================================================================================
    1)Exception Type 1:-
    java.io.FileNotFoundException: pic5.jpg (Access is denied)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
    at javax.imageio.stream.FileImageOutputStream.<init>(FileImageOutputStream.java:44)
    at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(FileImageOutputStreamSpi.java:37)
    at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:391)
    at javax.imageio.ImageIO.write(ImageIO.java:1483)
    at Test_ScreenShot.main(Test_ScreenShot.java:112)
    at Test_Main.main(Test_Main.java:466)
    at Test_ScreenShot.main(Test_ScreenShot.java:129)
    2)Exception Type 2:-
    "Exception in thread "main" java.lang.NullPointerException
    at Picture.width(Picture.java:84)
    at Test_Edge_Detector.not_main(Test_Edge_Detector.java:38)
    at Test_Main.main(Test_Main.java:88)"
    ============================================================================================
    Now I tried the following as alternative of ImageIO(from jdk 1.2)
    to read image:-
    FileInputStream fis = new FileInputStream(file);
    JPEGImageDecoder jpeg = JPEGCodec.createJPEGDecoder(fis);
    jpeg.decodeAsBufferedImage();
    fis.close();
    But after running a long time suddenly its giving following exceptions:-
    ==============================================================================================
    Exception Type 3:- )
    Exception in thread "main" com.sun.image.codec.jpeg.ImageFormatException: Not a JPEG file: starts with 0xff 0xd9
    at sun.awt.image.codec.JPEGImageDecoderImpl.readJPEGStream(Native Method)
    at sun.awt.image.codec.JPEGImageDecoderImpl.decodeAsBufferedImage(Unknown Source)
    Exception Type 4:- )
    javax.imageio.IIOException: Not a JPEG file: starts with 0xff 0xd9
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native Method)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(Unknown Source)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(Unknown Source)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(Unknown Source)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(Unknown Source)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Unknown Source)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(Unknown Source)
    at javax.imageio.ImageIO.read(Unknown Source)
    at javax.imageio.ImageIO.read(Unknown Source)
    at Picture.<init>(Picture.java:22)
    at Test_Edge_Detector.not_main(Test_Edge_Detector.java:37)
    at Test_Main.main(Test_Main.java:88)
    Exception in thread "main" java.lang.RuntimeException: Could not open file: pic45.jpg
    at Picture.<init>(Picture.java:27)
    at Test_Edge_Detector.not_main(Test_Edge_Detector.java:37)
    at Test_Main.main(Test_Main.java:88)
    My question is:-
    1)Where is the actual problem?Is it any kind of bug?
    2)I'm using the concept of piping recently to execute the application.Can it be the cause?
         When I googled I found the following informations.There is a bug in ImageIO while trying to write image file.But
    I'm not sure about that it will be relevent here :-
    1)from sun's bug database:-
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6247985
    2)from SUN Developer Forums
    http://forum.java.sun.com/thread.jspa?threadID=768917&messageID=4382833
    3)from Java.NET forum(here they r getting the bug while they r using createScreenCapture() method of robot class,I am
    also using that in my code)
    http://forums.java.net/jive/thread.jspa?messageID=123247
    4)from SUN's archieve
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0207&L=java-imageio-interest&D=0&P=1483
    5)Here is the actual implemetation of ImageIO class.I'm getting error at 391 no. line.
    http://kickjava.com/src/javax/imageio/ImageIO.java.htm
    Thanks And Regards
    Subhadip

    Hello,
    I am writng to ask a doubt I have been encountered. I have an array of Image URL's and I am downloading the images using thses URL for each index. The example for an image URL will be as follows:
    http://www.firstmonday.org/issues/issue6_10/wiggins/google-3oct2001.gifIf the URL is abroken link, I am getting the exception. But if the URL is somewhat hanging (which means when u open that URL in IE or Mozilla, the statuc bar for downloading the image will be hanging).
    So i want to set a timer for every link while downloading. may be 10min. My idea is if in that 10min, if code does not completes downloading the images, then ignore that link and proceed furthur.
    Can u please tell me how to write this.. Please tell me any other idea to tackle this problem.
    Thank you,
    Chaitanya

  • JSP read and write data in MS-SQL database

    I am new to JSP. I need to write JSP page to read and write data in MS-SQL Database. I wonder if it is different from other database. I couldn't find useful pointers in the web. Please advise. Thanks!!

    Sure, SQL Server is different from Oracle is different from MySQL is different from...
    But all of them can be accessed using JDBC:
    http://java.sun.com/docs/books/tutorial/jdbc/
    Maybe you should learn about that for starters.
    You can use SQL tags from JSTL in your JSPs. I'd recommend JSTL highly. No scriptlet code that way. - MOD

  • Read and write data from content repository .

    Hi All,
    We are using content repository to store some document and images on web center server .
    So we have created/setup a content repository on web center .
    Please proivde me some documnet /wiki page to get some idea how can i read and write date in
    content repository .
    You are most welocme to provide some idea /suggestion .
    Thanks,
    Arun.

    Have you already configured webcenter spaces so it can use content server?
    Have you installed the content server seperatly from webcenter or as a part of the webcenter installation?
    Check if you have the webcenter spaces component installed in content server because without i don't think it will work...
    If you already have configured UCM to work with spaces it's quiet easy.
    From your groupspace, open the settings page of your groupspace. Go to the services tab. In the left hand side you can enable the documents services. WHen you have done that, you are able to add the document services taskflows to your pages. Just go to a page in your pagegroup and edit it. Open the resource catalog and you will find some extra taskflows you can add.
    If you haven't configured UCM and webcenter to work together, here some steps that will help you:
    * Integrating UCM with Spaces
         * They both need to use the same LDAP store.
         * Since there is no LDAP server available, we choose for embedded WLS LDAP.
         * Integrating the ucm into apache
              * Stop UCM
              * In /oracle/product/wls10320/WebCenter/ucm/config/config.cfg, check the SocketHostAddressSecurityFilter to contain 127.0.0.1
              * Add the SocketHostAddressSecurityFilter to /oracle/product/wls10320/WebCenter/ucm/admin/bin/intradoc.cfg
              * Add to /oracle/product/wls10320/WebTier/instances/instance1/config/OHS/ohs1/httpd.conf
                   include /oracle/product/wls10320/WebCenter/ucm/data/users/apache22/apache.conf
              * Change the mod_wl_ohs.conf file to
                   <IfModule weblogic_module>
                         WebLogicHost localhost
                         WebLogicPort 7001
                         Debug ON
                         WLLogFile /tmp/weblogic.log
                   </IfModule>
                   <Location /webcenter>
                      SetHandler weblogic-handler
                      WebLogicCluster localhost:8888
                   </Location>
                   <Location /webcenterhelp>
                      SetHandler weblogic-handler
                      WebLogicCluster localhost:8888
                   </Location>
                   <Location /owc_discussions>
                      SetHandler weblogic-handler
                      WebLogicCluster localhost:8890
                   </Location>
                   <Location /em>
                      SetHandler weblogic-handler
                   </Location>
                   <Location /console>
                      SetHandler weblogic-handler
                   </Location>
                   <Location /consolehelp>
                      SetHandler weblogic-handler
                   </Location>
              * Restart UCM & WebTier
              * Test URL: http://yourServer:7777/idc
         * Configure the Identity Store for UCM & WebCenter
              * Set the password for the embedded ldap in WLS
                   Console => Domain Name => Security tab => Embedded LDAP tab => reset credentials
              * Restart AdminServer
              * Stop UCM
              * Add the following to /oracle/product/wls10320/WebCenter/ucm/config/jps-config.xml
                      <serviceInstance name="idstore.oid" provider="idstore.ldap.provider">
                          <property name="subscriber.name" value="ou=myrealm,dc=webcenter_domain"/>
                          <property name="idstore.type" value="WLS_OVD"/>
                          <property name="security.principal.key" value="ldap.credential"/>
                          <property name="security.principal.alias" value="JPS"/>
                              <property name="ldap.url" value="ldap://yourServer:7001"/>
                          <extendedProperty>
                              <name>user.search.bases</name>
                              <values><value>ou=people,ou=myrealm,dc=webcenter_domain</value></values>
                          </extendedProperty>
                          <extendedProperty>
                              <name>group.search.bases</name>
                              <values><value>ou=groups,ou=myrealm,dc=webcenter_domain</value></values>
                          </extendedProperty>
                          <property name="username.attr" value="uid"/>
                          <property name="user.login.attr" value="uid"/>
                          <property name="groupname.attr" value="cn"/>
                      </serviceInstance>
              * In the same file, change the serviceInstanceRef ref="idstore.ldap" to "idstore.oid"
              * Go to /oracle/product/wls10320/WebCenter/ucm/custom/FustionLibraries/tools
              * ./run_credtool.sh
                   Alias: default
                   Key: default
                   User Name: cn=Admin
                   Password: weblogic123
                   JPS Config: default
              * Start UCM
              * Check Provider:
                   * Go to http://yourServer:7777/idc
                   * Login : sysadmin/idc
                   * Administration -> Providers
                   * jpsuser should be good
                   * When a ldapuser exist, disable it!!
         * Configuring UCM for content search
              * Change the file /products/WebCenter11gR1/WebCenter/ucm/config/config.cfg
                  SearchIndexerEngineName=DATABASE.METADATA to SearchIndexerEngineName=DATABASE.FULLTEXT
              * Restart UCM server
              * Run the /products/WebCenter11gR1/WebCenter/ucm/database/oracle/admin/batchsnippet.sql in the wcbepsc_ocserver schema
              * Restart UCM server
              * Open the /products/WebCenter11gR1/WebCenter/ucm/bin/RepositoryManager (sysadmin/idc)
              * Recreate the indexes
         * Registering UCM with WebCenter
              * Go to http://yourServer:7777/em
              * Login with weblogic/weblogicPassword
              * Go to WebCenter - WebCenter Spaces - webcenter (WLS_Spaces)
              * From the top menu, select Settings - Service Configuration     
              * Select Content Repository
              * Add
                   Connection Name: ucm_connection
                   Repository Type: Oracle Content Server
                   Active Connection: checked
                   Administrator User Name: sysadmin
                   Root Folder: /WebCenterSpaces
                   Application Name: Spaces
                   CIS Socket Type: Socket
                   Server Host: localhost
                   Server Port: 4444
                   Authentication Method: Identity Propagation
              * Restart WLS_Spaces
         * Test the connection by creating a new group space and upload a document to the document page of this group spaceHope this helps.

Maybe you are looking for