arrayList question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NuCoder

    arrayList question

    How can i get an item out of an ArrayList to write to a file?
    I want to add the items to a collection to write them to a file.


  • Jon Skeet [C# MVP]

    #2
    Re: arrayList question

    NuCoder <me@me.com> wrote:[color=blue]
    > How can i get an item out of an ArrayList to write to a file?
    > I want to add the items to a collection to write them to a file.[/color]

    Which bit are you stuck on? What kind of items are you wanting to
    write, and in what format?

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Josip Habjan

      #3
      Re: arrayList question

      Hi,

      You can serialize arraylist and write it to file as xml. Also for creating
      arraylist from same xml use deserialization .
      Sample:


      I hope it helps ...

      Regards,
      Josip Habjan, Croatia
      URL: http://www.habjansoftware.com



      "NuCoder" <me@me.com> wrote in message
      news:eJVYCcgcFH A.3712@TK2MSFTN GP09.phx.gbl...[color=blue]
      > How can i get an item out of an ArrayList to write to a file?
      > I want to add the items to a collection to write them to a file.
      >
      >[/color]


      Comment

      • NuCoder

        #4
        Re: arrayList question

        the app was created by someone else so i'm trying to use the existing code
        in it. What's happening is that the app reads a file and validates the data
        in the file, if the data is invalid for any reason it writes an error to an
        Error arrayList then writes those errors to an text file. BUT I know need to
        write the error message to an excel file BUT I need to match the errors to
        the data that it is erroring out on. When I try to write the errors to the
        excel its only writing the last error.

        example:
        data looks like this
        BMW 20051212 John Smith New
        BMW 20041210 John Smith

        I have rules to check this data and validate the date format, and verify the
        make, name, price and new or used is there, since the price is not there an
        error would be created.

        "price not in file".
        so i need to write
        record 1 error
        BMW John Smith - price not included in file

        record 2
        BMW John Smith - indicator 'new' or 'used' not included in file

        how can i get both errors for the one record to write to my file? I get the
        last error to write but not both.




        "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
        news:MPG.1d1b22 7da81cc61b98c31 b@msnews.micros oft.com...[color=blue]
        > NuCoder <me@me.com> wrote:[color=green]
        >> How can i get an item out of an ArrayList to write to a file?
        >> I want to add the items to a collection to write them to a file.[/color]
        >
        > Which bit are you stuck on? What kind of items are you wanting to
        > write, and in what format?
        >
        > --
        > Jon Skeet - <skeet@pobox.co m>
        > http://www.pobox.com/~skeet
        > If replying to the group, please do not mail me too[/color]


        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: arrayList question

          NuCoder <me@me.com> wrote:

          <snip>
          [color=blue]
          > how can i get both errors for the one record to write to my file? I get the
          > last error to write but not both.[/color]

          Well, how are you currently getting the last error? Without seeing some
          of your code, it's hard to know what's going wrong.

          --
          Jon Skeet - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          Working...