Element in array to file

Hi!
I'm trying to get the elements in a array and put them into a file. How do I do that?
This is an example of how it looks:
Thearray: [a,1,b,2,c,3]
Thefile:
a
1
b
2
c
3
As you can see, each element should be on its own line in the file.

Here you have a way of doing it:
public static void main (String args[])
          String[] array_to = new String[5];
          array_to[0] = "a";
          array_to[1] = "b";
          array_to[2] = "c";
          array_to[3] = "d";
          array_to[4] = "e";
          try
               FileWriter fw = new FileWriter("file.txt");
               BufferedWriter bw = new BufferedWriter(fw);
               PrintWriter salida = new PrintWriter(bw);
               salida.println("" + array_to[0]);
               salida.println("" + array_to[1]);
               salida.println("" + array_to[2]);
               salida.println("" + array_to[3]);
               salida.println("" + array_to[4]);
               bw = new BufferedWriter(new FileWriter("fichero.txt", true));
               salida.close();
          catch(java.io.IOException ioex)
     }

Similar Messages

  • Is there a way to select a certain box of elements from a csv file and read that into LabVIEW?

    Hello all, I was wondering if there was a way to select only a certain "box" of elements from a .csv file in LabVIEW? I have LabVIEW 2011 and my main goal is to take two arrays and graph them against each other. I can import the .csv file just fine and separate each row and each column to be its own, but say I have an 8X8 but want to graph the middle 4X5 or something like that. Is there any way to extract an array without starting at the beginning and without ending at the end? Thank you in advance.
    Solved!
    Go to Solution.

    Hi Szklanam,
    as a CSV file is just a TXT file with a different suffix you can read a certain number of lines of that file. So you can limit the number of rows in your resultung array. To limit the number of columns you still have to use ArraySubset, so maybe it's a lot easier to read the full CSV file and pick the interesting spots with ArraySubset...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • 3D string array to file

    How can I write a 3D string array to file?

    sascha:
    You could do this a lot of different ways.
    The first and most obvious thing that comes to my mind is that you can
    think about a 3D array as an array of 2D arrays. (For that matter a
    2D array is an array of 1D arrays.)
    Thus you could use a for loop to index your 3D array down to 2D and
    then perform multiple writes to write each 2D array "element" of this
    array of 2D arrays to disk. You would probably want to write some
    sort of header which defines how many dimensions there are in the
    array so that whatever reads it back later will have an easier time
    reading it back. (Otherwise you'd have to implement EOF handling for
    the read back portion.)
    To read it back you just use the same logic but build a 3D array using
    a 2D read inside a for loop.
    Dou
    glas De Clue
    LabVIEW developer (looking for a job...
    [email protected]
    [email protected] (SaschaS) wrote in message news:...
    > How can I write a 3D string array to file?

  • Photoshop Elements 8-Change of file format when saving deletes filename

    I have been using Photoshop Elements 8 since last May and have always been irritated that when I add text to a photo it always defaults to PSD format for saving.  I have gone to the preference options to see if I can set jpg as the default and it does not offer that option.  This means that every time I save after adding text I have to manually select jpg to get the format to change.
    Although this has been a pain, I have done it thousands of times as I have edited photos.
    My problem is that suddenly from one day to the next when I change from PSD option to jpg the filename disappears and I have to go back and manually type in the whole filename.  The only changes to my computer settings that I can think of that might have affected this is that Microsoft Updates had 2 updates.  First was Definition for Windows Defender-KB915597 and the other was Unpdate for Windows 7 for x64 based systems-KB97690.
    I saw a similar problem posted by sandwitch2 on Feb. 13th about PSE6.  99jon suggested the change to permissions of adding "everyone".  I tried this and it did not correct the problem.
    Any other suggestions are welcome.
    I have found Adobe's insistance on saving as PSD irritating to say the least in the past.  The inability to change this in preferences has made me very unhappy, but the quality of their product has outweighed the hoops they make me jump through until this.  Their search feature in support is pretty much worthless.  It either brings up nothing if you keyword is to limiting or brings up 200 responses if it if too broad.
    I have been a user of Photoshop Elements for over 6 years updating as new editions have come out. I am to the point that if I can't get this current problem fixed I am uninstalling Elements 8 and going to another software.  Adobe's proprietary requirements and poor support page are just too much of a pain to deal with.

    I was told that if I save in PSD if I send the photos to share with others only those with Photoshop Elements can open the files.  That is why I try to use jpg.  Is that true?
    Thanks for all the help from both of you,
    Bettye

  • How to use the same element in different photoshop files?

    It occurs to me often that I use the same element in different photoshop files, a header or footer shown in the example below. So when the footer changes in one document, I need to change this footer in every other single document.
    Is there a possibility to use some kind of template, one single document,  that can be placed in different files , which is still editable afterwards?
    Thanks in advance.
    I'm using Photoshop CS6

    In a single document you can have several pages and these pages may have headers and footers that share smart objects.  If you replace the contents of the an embedded smart object on one page page that is shared on an other page the pages you will see both pages contents are changed. For they share the common object.   It is also possibly to have independent smart object layers. It depends how you create the layers in the single document.
    Example one sharing a smart object hi-light a smart object layer and use menu layer>Duplicate Layer... This will create a second smart object layer that share a common smart object. Each layer has is own associated transform. Do it again and you will have three layers the share a common smart object. So you can use each layer associated transform to position and size the layers contents. Make a picture package for example. When you hi-light any of the three smart layers and you use menu Layer>Smart Objects>Replace Contents... all three layers contents will be replace with the new smart object.  Care must be taken to replace the smart object with an identical size object for only the object is replaced the three associated transform for the three layers are not replaced or changed.
    Example two independent smart objects  hi-light a smart object layer and use menu layer>Smart Objects>New Smart Object via Copy.  This will  create a second smart object layer that has it own embedded smart object copy.  Do it again and you will have three all have independent embedded smart object that are identical.  However they do not have to remain identical.  For example if the first smart object layer was created by using ACR to open a RAW file as a smart object layer the embedded object is a copy of the raw file and its associated RAW conversion settings.  Double clicking on one of the smart object layers and you will see ACR open on its embedded RAW file with the embedded RAW conversion setting.  Changing these settings will update the layer smart object content with new ACR setting and pixel when you click OK in ACR. Repeat for the third and you will find you have three different raw conversions in Photoshop you can mask and blend together to bring out detail.
    I think what your missing is that a smart object contains a copy of the original object.  Changing the original after creating a smart object layer in document will not effect the smart object layer at all. Its independant from the original having a copy of the original. Only changes to the smart object layer and its embedded smart object effect smart object layers.

  • How do I find out the size of each individual element within a photoshop file as need to replace some elements?  Thanks :)

    How do I find out the size of each individual element within a photoshop file as need to replace some elements?  Thanks

    What do you mean by "Elements"?
    Elements in a flat image or Layers?
    Could you please post a screenshot with the Layers Panel visible?

  • How to update/change the value of elements in an xml file?

    Hi Everyone,
    Could any one of u tell me how to update the value of elements in an XML file, using java? The reason is i want to use an XML file as a data source (i.e. more or less like a database), without using any RDBMS, for simple applications such as to read a record and update the record. By the way, my XML file will have only one record, such as the current weather information, with fields such as temperature, humdity etc. for 1 city only.
    Thanks in advance.

    Here is a solution how to check a particular value or element name in an xml and update the changes e to an xml.
    Sample.xml
    <URLConstructor>
    <application name="cp_outage">
    <resource>hello</resource>
    <value>val</value>
    </application>
    <application name="cp_outage">
    <resource>hello</resource>
    <value>val</value>
    </application>
    </URLConstructor>
    XMLWriter.java
    package com;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.JDOMException;
    import org.jdom.input.DOMBuilder;
    import org.jdom.output.XMLOutputter;
    // used for printing
    import org.apache.xml.serialize.XMLSerializer;
    import org.jdom.output.XMLOutputter;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.util.Iterator;
    import java.util.List;
    class XMLWriter{
    public void update(File fileName)
    try {
              DOMBuilder domBuilder=new DOMBuilder();
              Document doc=domBuilder.build(fileName);
              Element element=doc.getRootElement();
              getChildren(element);
              writeToXML(doc,fileName);
              getChildren(element);
    } catch (Exception e) {
    e.printStackTrace();
         * @param doc
         private void writeToXML(Document document,File filePath)
                   XMLOutputter xmloutputter = new XMLOutputter();
                        try
                             FileOutputStream fileOutputStream = new FileOutputStream(filePath);
                             xmloutputter.output(document, fileOutputStream);
                             fileOutputStream.close();
                        catch (FileNotFoundException e)
                             e.printStackTrace();
                        catch (IOException e)
                             e.printStackTrace();
         public void getChildren(Element element)
                        if(!element.hasChildren())
                             return;
                        List childrenList = element.getChildren();
                        Iterator itr=childrenList.iterator();
                        while(itr.hasNext())
                             Element childElement=(Element) itr.next();
                             if(childElement.hasChildren())
                                       getChildren(childElement);
    //                                   System.out.println("Name "+childElement.getName());
    //                                   System.out.println("Value "+childElement.getText());
                                       if(childElement.getText().equals("hello") || (childElement.getName().equals("resource")))
                                            updateInfo(childElement,"New_Resource","AddedText");
         * @param childElement
         * @param string
         * @param string2
         private void updateInfo(Element element, String elementName, String value)
              element.setName(elementName);
              element.setText(value);          
    static public void main(String[] args)
    XMLWriter xmlWriter=new XMLWriter();
    xmlWriter.update(new File("c:/sample.xml"));
    After execution the file will be changed to
    <URLConstructor>
    <application name="cp_outage">
    <New_Resource>AddedText</New_Resource>
    <value>val</value>
    </application>
    <application name="cp_outage">
    <New_Resource>AddedText</New_Resource>
    <value>val</value>
    </application>
    </URLConstructor>
    Regards,
    Maheswar

  • Elements 13 - a jpg file always opens in B & W raw and I cannot get it to open in colour. Same file open OK in colour in Elements 9. Any suggestions how I can get it to opens in colour in Elements 13?

    Elements 13 - a jpg file always opens in B & W raw and I cannot get it to open in colour. Same file opens OK in colour in Elements 9. Any suggestions how I can get it to open in colour in Elements 13?

    Thanks for your reply - I just open the file with "Open" in the File menu - all my own jpg files open fine in colour. This is someone else's photo given to me and it does not matter how I open it "Open", "Open in raw" or "Open with ..." it always opens in B & W raw in the raw dialogue box. In Elements 9, which I also have on my PC it opens fine as jpg in colour so I can edit it there, but I am just wondering why I am getting this problem in elements 13. If I open it in any other programme such as Windows Photo viewer or Office 2010 viewer it opens fine in colour.
    Not sure what you mean by "basic settings" menu.
    Thanks for the reply

  • Edge Animate CC 2014 animation of elements of a html file created in Dreamweaver

    Does anyone know why with Edge Animate CC 2014 it's not possible anymore to animate elements of a html file created in Dreamweaver? With Edge Animate CC 3.0.0. this was possible.

    Hello!
    I now have a project that seems to be corrupted. A had been working on it all morning, with a few bugs here and there. Now I can no longer open the file, receiving this error: "Edge Animate: Exception An error occurred. Please your work and restart Edge Animate."
    I will try to attach sample files.
    - J Sean

  • Writing data from array to file

    May i know how to write string from a array into a file.
    I have use string tokenizer to extract every line from a file using readline and use stringtokenizer to spilt the line using tab delimiter for processing.
    But if i want to write data from array to file with tab as a delimiter and how to go to the next line. How do i do that. Below is the task and i have state a simple example on a array i have and the file output that i want.
    Pls advice.. Thanks
    eg of a array
    array[0] = Data
    array[1] = One
    array[2] = Data
    array[3] = Two
    array[4] = Final
    array[5] = Data
    From the above array, i want to write to a file so that it will appear something as below
    Eg textfile.txt
    Data One
    Data Two
    Final Data
    PLs attached a simple code as a example as i am only begining to start useing the IO feature in java. Thanks

    Really thanks for your help,
    but u are mentioning that i have already know the number of countters in advance , that is to say the 2 * counters.
    But is there a way to solve this problem which i mean if i dun know the number of predefined counters. Maybe i should say, there is more than 2 counters and in another situation, the counters will only be defined during runtime. Actually the solution u give will work nicely with 2 counters. but wat if the counter is more than 4, i wll have to concatenate the string a lot of time. so is there any solution around this problem. That why i am wandering if tere is any solution to write to the file when the counters can be only determined in runtime
    Pls advice on the above with a code samples if possible.

  • Mac os 10.9.5--elements 10--go to file import and my scanner isn't listed

    mac os 10.9.5--elements 10--go to file>import and scanner not gown

    The members of the Photoshop Elements forum can best answer and followup on your question.
    Gene

  • How to avoid the presence of element in the Destination file if the value is empty

    Hi,
    I am using a map, in which Source is an XML File, Destination is a FlatFile
    For Eg:
    Input File
    <Name>
    FirstName>aaa</FirstName>
    <LastName>bbb</LastName>
    </Name>
    Output File
    FirstName     LastName
    aaa                bbb
    Destination Schema is also the same, but if the Last name value is empty, the LastName element should not be present in the Destination Flat File.
    Eg:
    Input File
    <Name>
    FirstName>aaa</FirstName>
    <LastName></LastName>
    </Name>
    OutputFile should be
    FirstName
    aaa
    Please help in making this requirment....
    Regards, Vignesh S

    Set the “Min Occurs” property of the LastName header element in the flat-file schema to “0” (Zero)
    Create a map which maps the Schema for the XML file to the flat-file schema.
    In the map, use the Logical Existence and Value mapping as shown in the below image. Here Logical
    Existence function is used to check the existence of the field LastName in the input XML. If LastName element exist, then using the Value mapping functiod, map the Contant-LastName  (this
    would be the header). Below image shall help you with thisexplanation.
     As you can see, for the detail record, the value is mapped directly and for the header, as per you requirement a check has been made to for the existence of the LastName
    field in the XML to populate the LastName header node. If LastName is empty in the XML, header LastName would not be populated.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

  • Due to Photoshop Elements 12 Organizer I uninstalled the program.  When I re-installed Photoshop Elements 12 on the same computer the "Photoshop Elements 12.0.exe" file is not available.  I have tried loading Photoshop Elements 12 from the Adobe web site

    Due to Photoshop Elements 12 Organizer I uninstalled the program.  When I re-installed Photoshop Elements 12 on the same computer the "Photoshop Elements 12.0.exe" file is not available.  I have tried loading Photoshop Elements 12 from the Adobe web site without success.

    The Elements 12 shortcut can't find the Elements12.0.exe file so the program will not load.  I can load the editor from its .exe file but not the organizer.

  • Does Elements 12 support Raw files from Nikon D610

    Does Elements 12 support Raw files from Nikon D610

    Yes, as long as you update your camera raw plug-in (ACR) to version 8.3 using Help / Updates… in the PSE Editor.

  • Merging elements of array

    Hi,
    I am new to programming.
    I have a sensor that sends a data stream through a serial port. I have collect all that data in a 1D unsigned byte array. Now, lets say my 1-D array is [12][45][65][12]...... where each "[ ]"  is a element of the array. Now to make sense of this data what i need to do is merge two elements the array and multipy it by 2/(2^15). i.e. My converted data should by [1245]*2/(2^15). Basically 2 bytes together makes sense. I can do a simple add of each element. Also the other problem is,data from the sensor is a stored as the 1-D array  of unsigned byte. However, the converted data is supposed to be signed 16-bit integer.
    Please give any suggestions on how to go about doing this.
    Siddhant Shah

    Another option is "decimate&Join". (Here it is easy to change the byte order if needed).
    Message Edited by altenbach on 12-15-2008 06:28 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    8bitTo16BitByteOrder.png ‏5 KB

Maybe you are looking for

  • Is it possible to upgrade iq526 graphics ?

    i just purchased an iq526 and altho the graphics are ok i would like to see faster frames on game like world of warcraft. Can i upgrade this video card to say a a 9600m from its current 9300m ? if that is possible could i get a link to the area i wou

  • Issue with paper type when remote printing

    Hello we have an issue with printing from redirected printer on the local machine Windows 8.1 i have a printer installed and when i try to print from a remote pc to my installed printer on my local pc the paper type is replaced. on the local printer

  • Xfi extreme audio SB0790 Windows Home Premium

    I have installed Windows 7 upgrade on an HP desktop that was running XP Pro. Install went fine exept I have an error "No Audio Device Installed"? yet I have installed the Xfi extreme audio card in its slot. The card works fine with XP. I have gone wi

  • Selection screen generation

    hi, in my main dialog program, i created a selection screen using statements selection-screen.... i activated it and was able to see that at runtime.. i noticed that the same selection screen was listed in the tree in SE80 under my package under scre

  • What is Joint Stereo?

    Just wondering what "Joint Stereo" is? In iTunes Preferences, it says "Details-80 kbps (mono)/160 kbps (stereo), joint stereo, optimized for Velocity Engine." I have it set to 160 kbps. But I noticed that some of my songs are "joint stereo" and some