How convert from vector to Byte array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dpsairam
    New Member
    • Jul 2008
    • 6

    How convert from vector to Byte array

    Hi,
    How to convert a Vector to a Byte array....i have vector which contains a Byte array.....i need to convert the vector into Byte array...

    --------------------------------------------------------------------------------
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by dpsairam
    Hi,
    How to convert a Vector to a Byte array....i have vector which contains a Byte array.....i need to convert the vector into Byte array...

    --------------------------------------------------------------------------------
    Is your vector a Vector<Byte> or a Vector<Byte[]> or a Vector<byte[]>?

    kind regards,

    Jos

    Comment

    • dpsairam
      New Member
      • Jul 2008
      • 6

      #3
      Is your vector a Vector<Byte> or a Vector<Byte[]> or a Vector<byte[]>?


      can you tell me what is the difference between these three

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by dpsairam
        can you tell me what is the difference between these three
        A Vector<Byte> contains objects of type Byte; a Vector<Byte[]> contains arrays and each element is a Byte type object. A Vector<byte[]> contains arrays of bytes; they are of primitive type.

        kind regards,

        Jos

        Comment

        • dpsairam
          New Member
          • Jul 2008
          • 6

          #5
          my vector is Vector<byte[]>

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            So you have a lot of these byte arrays (byte[]) in a Vector. And you want to 'convert' them to just one byte[]? What are the rules for the conversion?

            Comment

            • dpsairam
              New Member
              • Jul 2008
              • 6

              #7
              Originally posted by r035198x
              So you have a lot of these byte arrays (byte[]) in a Vector. And you want to 'convert' them to just one byte[]? What are the rules for the conversion?
              what rules.......... ????dint get u

              Comment

              • dpsairam
                New Member
                • Jul 2008
                • 6

                #8
                Originally posted by r035198x
                So you have a lot of these byte arrays (byte[]) in a Vector. And you want to 'convert' them to just one byte[]? What are the rules for the conversion?
                see i have a byte array in Vector i want to extract that byte array from this vector

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Is there only one byte[] in the Vector then?
                  That simplifies matters somewhat.
                  Now all you need is to know what position in the Vector the array is at. Suppose the array is at index 41, then you simply do the simple
                  Code:
                  int thePosition = 42; 
                  byte[] theExtractedByteArray = (byte[])myVector.get(42);
                  1.) If you use generics you won't need the cast.
                  2.) Why do you have Vector if you only have one byte[] to store?
                  3.) Why did you use Vector instead of ArrayList?

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by dpsairam
                    what rules.......... ????dint get u
                    Suppose you have three arrays in the Vector with the following elements:

                    a1, a2 b1, b2, b3 and c1, c2

                    How do you want to store those seven elements in one array? There are several options and you know the 'rules', not us because we're not psychic.

                    kind regards,

                    Jos

                    Comment

                    • JosAH
                      Recognized Expert MVP
                      • Mar 2007
                      • 11453

                      #11
                      Originally posted by r035198x
                      Suppose the array is at index 41, then you simply do the simple

                      int thePosition = 42;
                      byte[] theExtractedByt eArray = (byte[])myVector.get(4 2);
                      *ahem*

                      kind regards,

                      Jos ;-)

                      Comment

                      • r035198x
                        MVP
                        • Sep 2006
                        • 13225

                        #12
                        41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41

                        Silly fingers, that should teach them to type of their own accord.

                        Comment

                        • JosAH
                          Recognized Expert MVP
                          • Mar 2007
                          • 11453

                          #13
                          Originally posted by r035198x
                          41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41

                          Silly fingers, that should teach them to type of their own accord.
                          I never have that.

                          kill regexp

                          Java ;-)

                          Comment

                          • JosAH
                            Recognized Expert MVP
                            • Mar 2007
                            • 11453

                            #14
                            @OP: I wonder how you got that byte[] in your Vector if you don't know how to get that element out of it.

                            kind regards,

                            Jos

                            ps. I noticed you reporting this thread; better concentrate on being clear so that we can answer your extremely vague question instead.

                            Comment

                            Working...