Casting Byte[] to byte[]

This might be a basic java problem but im having problem here.
I have a variable declared as Byte array(Byte[]) and I want to transform it to byte array(byte[]).
How can that be done.
I went through the API, googled but couldnt find a solution.
any help will be appreciated.
Thanx in advance.

You can't transform an array of Byte into an array of byte.
But you can create a new array of byte with the same length as the array of Byte and copy all the values from it.

Similar Messages

  • Getting error while tring to Check in any document in Sharepoint 2007. Error - "Unable to validate data. System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) ...

    Hi Team,
    I am getting error while tring to Check in any document in Sharepoint 2007. Error - "Unable to validate data. System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength).
    Anybody please let me know how to resolve the issue. It has affected our 9 site collection with almost 2000+ sites. Please email me your your suggestion or you can share your ideas here also.
    Tried to reset the IIS, checked the Internet connection speed (8MBps). Cleared the cache and all but no luck.
    Thanks,
    Pronob

    Hello,
    I have found this support window for you:
    http://support.microsoft.com/kb/556031
    http://technet.microsoft.com/en-in/library/cc298582%28v=office.12%29.aspx
    This may help you
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Should I use a temp buffer to gunzip bytes to bytes?

    Folks,
    I need a method to gunzip (uncompress) a zipped-byte-array into a plain-byte-array ... The below method (based on that used for file-i/o-streams) works, but I can't figure out if using the buf  "interveening temporary buffer" is good, bad, or indifferent.
    As I understand things... There's really no memory saving in reading/writing-by-the-temporary-buffer because the input gzippedByteArray is allready wholey in memory, and we (by definition) need the whole output plain-byte-array in memory concurrently... so it'd probably be more memory efficient to NOT use temporary-buffer and just zip the WHOLE input straight into the ByteArrayOutputStream with one call to output.write
    BUT I'm not really sure of myself here... so please can anyone offer an informed opinion?
    Memory efficiency is important (I think) because we're handling XML responses, and "the odd one" might be upto maybe 200 Mb (unzipped), though "the norm" is under a meg, and 99% are under 5 meg... So I guess I need to engineer this instead of just slapping it in and seeing if it pops.
          * Returns the g-unzipped (uncompressed) version of the given
          * gzippedByteArray.
          * @param gzippedByteArray byte[] - the bytes to uncompress
          * @return byte[] - the uncompressed bytes
          * @throws IOException
         public static byte[] getUnzippedBytes(byte[] gzippedByteArray)
              throws IOException
              ByteArrayInputStream input = null;
              GZIPInputStream unzipper = null;
              ByteArrayOutputStream output = null;
              byte[] bytes = null;
              try {
                   input = new ByteArrayInputStream(gzippedByteArray);
                   unzipper = new GZIPInputStream(input);
                   output = new ByteArrayOutputStream();
                   // unzip bytes onto the output stream
                   int len;
                   byte[] buf = new byte[BUFFER_SIZE];
                   while ( (len=unzipper.read(buf)) > 0 ) {
                        output.write(buf, 0, len);
                   // return the contents
                   bytes = output.toByteArray();
              } finally {
                   IOException x = null;
                   if(unzipper!=null) try{unzipper.close();}catch(IOException e){x = e;}
                   if(output!=null) try{output.close();}catch(IOException e){x = e;}
                   if(x!=null) throw x;
              return bytes;
         }Thanking you all. Keith.

    OutputStreams aren't 'exposed by routers... Our bluddy router "encapsulates" the servlet request. It exposes a swag of setters, one of which is setExtractXml(byte[])... the upside is that you don't have to worry about content types, and request headers and all that carp... the downside is the loss of flexibility.
    What I meant was that I'll need to customise the session model (which lives in our funky router) to expose the servlet-output-stream to the action class... Then we're laughing.
    Or not... My mad tech manager reckons "it's been working that way for years"... he didn't like it when I reminded him of our "odd "unexplained" out of memory" incidents... Nope... His code... His way... Gotta luv the managment, and why do I care anyway... Do I care? Naaah. I just work here.

  • Register() and register(byte[], short, byte)

    According to JavaCard 2.2.1 API:
    register()
    -This method is used by the applet to register this applet instance with the Java Card runtime environment and to assign the Java Card platform name of the applet as its instance AID bytes.
    register(byte[], short, byte)
    -This method is used by the applet to register this applet instance with the Java Card runtime environment and assign the specified AID bytes as its instance AID bytes.
    1. As far as I know, the later is used for assigning specific instance AID. But if the register() is used, what is the instance AID?
    2. If I have registered only one instance with JCRE, should I select it by its applet AID or instance AID? Why is it so?
    Thanks!

    upz , sorry maybe my question is not right ,arent ?.. correctly I ask how to configure OCF on my linux, so I can connect my smart card reader , smart card and the host application (that develop with OCF) .
    thank for reply..
    Correctly ,.. I have more question..about applet. For you knowing I am developing smart card as ID and password to access computer application..can you help me ?
    my question :
    if I want to storage ID and password data to smart card memory .. where I must to place these data, so I can update that data on other time..
    do you have some code that similiar with my applet ?
    thank ..

  • Read byte by byte

    Hi. I'm using the module "bytes at serial port" to read the answers of my robot, but i do not want to read all bytes at the same time. I want to read byte by byte. How can i do it?
    Thanks.
    Ivan.

    So it seems as if ">" is the character that signals the termination of a command.  Use this as your termination character, and initialize the serial port that way.  See picture of how to do this (">" is ASCII 62 in decimal).  When reading, the ">" character will signal the termination and the reading will stop.  Other characters afterwards will remain in the buffer until the next read.
    You should fix your code to prevent infinite loops in case the termination character is not received.  What happens if the character is never sent due to some glitch in the sending system, or if some glitch causes a different character to be received instead of ">", or if the comm link breaks before ">" is received?  Your program will get stuck.  You need to fix this by putting a timeout or something that will abort or end the code in case something goes wrong.
    Message Edited by tbob on 06-12-2006 10:25 AM
    - tbob
    Inventor of the WORM Global
    Attachments:
    Term.png ‏1 KB

  • When I try to install "Addblock Plus", a pop-up box displays "Add-on downloading", and "unknown time remaining - 0 bytes (0 bytes / sec)". My local area connection status box shows that it is connected but that nothing is being received.

    I am using Firefos 9.0.1 under Windows XP. I use Avast anti-virus. My Add-ons bar is empty. I have not initiated the installation of any plug-ins. Downloads keeps no record of my attempts.

    Thank you for your interest mha007. This is an update on my evenings activities so far.
    I have done that trouble shooting with results, as follows:
    Started in safe mode
    In Tools/Options/Advanced/General, I unchecked "Use hardware acceleration when available"
    Clicked on Tools/Add-ons
    "Get add-ons" displayed "Loading" indefinitely
    All 5 Extensions are dis-abled: it suggested that I remove "Microsoft.net framework assistant 1.2.1" & "Test pilot 1.2".
    On "Microsoft.net framework assistant 1.2.1" I Clicked "Remove". It remained but with version 0.0.0.
    On "Test pilot 1.2" I clicked "Remove". It disappeared.
    The single Appearance "Default 9.0.1" is disabled
    None of the 16 plug-ins are disabled.
    I clicked on Add-ons and "Get add-ons" displayed "Loading"
    Several minutes later I found that, "Add-ons" had loaded.
    I clicked on "Most popular" and then on "Add to Firefox " within "Adblock plus"
    A pop-up box displayed "Add-on downloading", and "unknown time remaining - 0 bytes (0 bytes / sec)".
    Within a minute, a Firefox "Alert" pop-up window opened with the message: "An error occurred during a connection to www.mozilla.org:443 / The OCSP server experienced an internal error. / (Error code: sec_error_ocsp_server_error)"
    I bookmarked the "Most popular add-ons page"
    I closed Firefox and opened it again - not in safe mode.
    Clicked on Tools/Add-ons. "Get add-ons" displayed "Loading".
    In Extensions, on "Microsoft.net framework assistant 1.2.1" I Clicked Disable", and Restart Firefox
    I clicked on Tools/Add-ons. "Get add-ons" displayed "Loading". Message displayed "Connected to services.add-ons.mozilla.org. Waited.
    10 minutes later I opened a new tab and clicked on the "Most popular add-ons page" bookmark. Message displayed "Connected to add-ons.mozilla.org". Waited.
    15 minutes later, neither of the tabs had responded. I re-started firefox in safe mode
    I clicked on Tools/Add-ons. "Get add-ons" displayed "Loading". Message displayed "Connected to static-ssl-cdn.addons.mozill.net"
    Using the new tab from above which was not active on restart, I clicked on the "Most popular add-ons page" bookmark.
    The bookmarked page opened. I clicked on "Add to Firefox " within "Adblock plus"
    Again, a pop-up box displayed "Add-on downloading", and "unknown time remaining - 0 bytes (0 bytes / sec)". (No Alert this time).
    I don't know what to read into all of this. Any advice on what the next best thing to do would be appreciated.

  • Vector with bytes to byte[ ]

    I have a Vector with bytes as it elements:
    Vector _buffer = new Vector();
    byte a = 120;
    byte b = 67;
    byte c = 98;
    _buffer.addElement(a);
    _buffer.addElement(b);
    _buffer.addElement(c);And I want to read it our into a byte[ ], so it is more easy to, for example, make a string of it. So I want to do this:
    byte[] b = (byte[]) _buffer.toArray(new byte[0]);But this isn't working, probably because byte is a primitive, and the function Vector: public <T> T[] toArray(T[] a) works on classes (I am not sure about this...?)
    The following is working:
    Vector _buffer = new Vector();
    Byte a = new Byte(120);
    Byte b = new Byte(67);
    Byte c = new Byte(98);
    _buffer.addElement(a);
    _buffer.addElement(b);
    _buffer.addElement(c);
    Byte[] b = (Byte[]) _buffer.toArray(new Byte[0]);But this isn't what I want, because even now I can't make a byte[] out of the Byte[]. Is there an easy way (loops off course, but maybe a more elegant way) to bridge this gap between primitives and classes?
    Thanks in Advance

    Geert wrote:
    I don't see how to work with the ByteArrayInputStream...? The socket only returns me an InputStream, so how to convert it to an ByteArrayInputStream?I said ByteArrayOutputStream, not ByteArrayInputStream.
    You're reading from the stream and adding the bytes to a Vector<Byte>, right? Instead of storing them in a Vector<Byte>, write them to the ByteArrayOutputStream instead. Then you can call toByteArray() to get a byte[].
    EDIT: I should've limited my quote in reply #5 to this part:
    I need to have a dynamical created array. Because the order of the List is important I thought I would need to use a Vector object.

  • Why no Byte.toBinaryString(byte b) method?

    I don't get it.
    There's an Integer.toBinaryString(int i) method...
    a Long.toBinaryString(long l) method...
    But no Byte.toBinaryString(byte b) method.
    Uh, WTF?

    I was able to get what I needed with the following method:
         public static String format(byte b)
              String binaryString = Integer.toBinaryString(b & 0xFF);
              while(binaryString.length() < 8) binaryString = "0" + binaryString;
              return binaryString;
    The point is, there is no knowable reason Sun couldn't provide a Byte.toBinaryString method as a convenience.

  • How an i play video data coming byte by byte over a n/w

    Actually i have written a java program where i am receiving a video file in bytes using udp packets from a server trhough LAN. I want to play each packet as soon as it it received on the client side in its original format without storing the data on client machine. i dont want to use JMF. can i do this without JMF?
    please help me with some sample code...

    This question likely relates to the one you asked earlier and is clear crosspost (exact copy) of one you posted earlier. Please cut that out.

  • How can I convert stream to byte and byte to stream

    I got a IInputStream from BackgroundDownloader operation, how can I convert it to byte array? I try to convert it to buffer and after that to bytes, but it's always throw exception.
    function decryptStream(inputStream, totalBytes) {
    var reader = new Windows.Storage.Streams.DataReader(inputStream);
    var iBuffer = reader.readBuffer(totalBytes);
    var bytes = Windows.Security.Cryptography.CryptographicBuffer.copyToByteArray(iBuffer);
    Could I have examples about that?

    Hi Jeft,
    In my program, I have a BackgroundDownloader to download an image. When we have result, I will convert it to bytes array.
    if (p.hasResponseChanged && imageStream == null) {
    imageStream = operation.getResultStreamAt(0);
    if (!p.hasResponseChanged && imageStream != null) {
    decryptStream(imageStream, p['bytesReceived']);

  • How to using the JSP print the byte[] or byte?

    how to do?

    this byte[]'s content is a PIC,if let this byte[] to string did print is character string, not the PIC.you see?:)

  • Byte array (byte[]) in session

    Is it possible to put byte[] in servlet session? Is correct?
    byte[] is it serializable? Is a object?

    yes you can put byte array into session.

  • Object to byte [] and byte [] to Object

    Hi,
    I am quite new to java and need some help. My question is how can I convert an Object to byte [] and convert back from byte [] to Object.
    I was thinking of something like:
    From object to byte []
    byte [] object_byte=object.toString().getBytes();
    When I try to do:
    String obj_string=object_byte.toString();
    But obj_string is not even equal to object.toString().
    Any suggestions?
    Thanks

    // byte[] to Object
    byte[] b = new byte[]{1};
    Object o = (new ObjectInputStream(new ByteArrayInputStream(b))).readObject();
    // Object to byte[]
    Object o = new Object();
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();    
    ObjectOutputStream objStream = new ObjectOutputStream(byteStream);       
    objStream.writeObject(o);  
    byte[] b = byteStream.toByteArray();

  • Java Serial Port - byte by byte reception.

    I want to receive one character after the other over my serial port. Could some one tell me how to control the data flow during reception.
    case SerialPortEvent.DATA_AVAILABLE:
    ReadBuffer = new byte[1];
    try
    if(serialPort.isCTS())
    while (inputStream.available() > 0)
    int numBytes = inputStream.read(ReadBuffer);
    ReadString = new String(ReadBuffer);
    rb.append(ReadString);
    }

    case SerialPortEvent.DATA_AVAILABLE:{
    while(true)
    try
    ch = is.read();
    if(ch==-1)
    break;
    buf.append((char)ch);
    }catch(IOException ioe)
    }

  • How to change the image into byte and byte array into image

    now i am developing one project. i want change the image into byte array and then byte array into image.

    FileInputStream is = new FileInputStream(file);
    byte[] result = IOUtils.toByteArray(is);
    with apache common IO lib

Maybe you are looking for