How do I store an Int, a short, and multiple bytes from file in byte array

I'm attempting to do this for a project but can't figure out how to store the three values in one byte array. This is what i've tried
public void send(byte[] input)
          // TODO
          ByteArrayInputStream bais = new ByteArrayInputStream(input);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          DataOutputStream dos = new DataOutputStream(baos);
          byte[] pData = new byte[100];
          try {
               dos.writeShort(checkSum);
               dos.writeInt(nextSeqNum);
               pData=baos.toByteArray();
               bais.read(pData);
          } catch (IOException e) {
          DatagramPacket dgp = new DatagramPacket(pData, pData.length);When i set pData=baos.toByteArray() it changes the size and then stops me from being able to read the other 94 bytes into the array to send. Any ideas?

You don't need the ByteArrayInputStream at all.
dos.writeShort(checkSum);
dos.writeInt(nextSeqNum);
dos.write(input);
pData = baos.toByteArray();
When i set pData=baos.toByteArray() it changes the sizeNo, it makes it refer to a new byte[] array containing what you've written to the BAOS. That's what it's supposed to do.

Similar Messages

  • How can I store movies in the cloud and access them from my devices?

    Hello,
    I would like to store movies in the cloud and access them from my device without having to download them to the device because there is not enough space on the harddrive to store them on it. How would I do this? Would I have to download the movies to my PC or could I store them directly in the cloud?
    Thanks,
    Tyler

    Unfortunately I don't use sugarsync myself, I have a dropbox account and it works slightly differently.
    As I understand it you can upload files to a folder in sugarsync from your computer without having them sync to any of your devices. You can access that folder from any of your devices, and although you would need to download them in order to play the video file, you could then delete them without deleting the files in the sugarsync folder in the cloud.

  • How do I bulk upload documents using PowerShell and extract metadata from file name?

    I have a requirement to upload a bunch of documents into a document library. Based on the content type, the rules of updating the metadata is different...the one giving me trouble is to extract the metadata from the file name. If I have a file name like
    "part1_part2_part3.pdf" how do I extract part1, part2, part3 and tag each document being uploaded into SharePoint, using PowerShell? I have searched and have not been able to find anything to get me started.
    Has anyone done this before? Or is there a blog I can take a look at? Thanks
     

    You will have to write a PS script encompassing this logic.
    Read files from the folder using
    Get-Item cmdlet
    Determine the content type based on the path or filename.
    Split the file name to extract the tag names.
    If the metadata fields in the content type is a managed metadata field, check whether the term exists and set it.
    Updating SharePoint Managed Metadata Columns
    with PowerShell
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • In ECC6,how to use tcode se63 to translate short and long texts?

    In sap 4.6c, I know how to use tcode se63 to translate short and long text. However, in ecc6,when i use se63 to translate abap data element short  texts, i cannot save it .A error message appare: Could not save target text  Message no. SKTY000.
    Can any body help me?

    Hi,
    This is  because o source language must be different from target language.
    regards,
    Eduardo Marcelino

  • How can I store movies in the cloud and access them on my devices without having to download them to them?

    Hello,
    I would like to store movies in the cloud and access them from my device without having to download them to the device because there is not enough space on the harddrive to store them on it. How would I do this? Would I have to download the movies to my PC or could I store them directly in the cloud?
    Thanks,
    Tyler

    Would I have to download the movies to my PC or could I store them directly in the cloud?
    There is good news coming!
    Technology experts are working on a movie storage system where YOU have physical possession of the movie.
    This system stores the movie digitally on an optical disk system that will not be dependent upon a congested, complicated, and fragile network.
    Because all of the data is stored only a few feet from your television, all the bottlenecks are removed.  Performance and reliability are virtually flawless.
    Further, the system will not utilize any form of security codes, authentications, or passwords. Once the optical disc is purchased it can be moved around freely at will, and can even be lent or given to friends and neighbors with zero hassles.

  • Why and how does Adobe Store's policy deliberately impede Least Developed Countries from developing?

    Hi there,
    My name is Dr Eric Mousset. I currently reside in Cambodia, having the privilege to serve as (international) Technical Assistant to support a Government project that is co-funded by the Royal Government of Cambodia and the World Bank, and purposed to Higher Education Capacity and Quality Improvement.
    My mission implies conducting a survey on skills demand by employers and skills supply by Higher Education Institutions, in order to better inform further policy development.
    Among the expected policy outcomes: a more effective alignment between skills supply and job market needs. 
    Among the desired policy impacts: providing the Cambodian economy with the HR skills that are required for its growth and diversification.
    I am impressed by the combined capabilities of Adobe Acrobat XI Pro and Adobe Forms Central. And until this morning it was on top of my shortlist of surveying tools.
    Unfortunatley, while attempting to upgrade to FormsCentral's "Plus" plan, I have received the following reply from Adobe:
    Unsupported Country
    Thus here is my question:
    Why and how does Adobe Store's policy deliberately impede Least Developed Countries from developing?
    Yours sincerely,
    Dr Eric Mousset

    Hi;
    I can't speak to the business decisions that lead to which countries we enable purchasing subscriptions in the store, but I can guarantee you that it is not to impede anyones development. 
    A credit card with an address in any of the supported countries can be used for purchasing the subscription, this has enabled many to get around the issue, but that is the only way to subscribe.
    Thanks,
    Josh

  • Updated my 4s and ipad3 and now both are basically useless. Cant access itunes store, app store, weather app wont work and multiple bugs with facebook. How am I supposed to fix all these problems????

    Updated my 4s and ipad3 and now both are basically useless. Cant access itunes store, app store, weather app wont work and multiple bugs with facebook. How am I supposed to fix all these problems????

    Hi Doomtrooper,
    When you updated your iPhone 4S and iPad3 to iOS6, what exactly do you mean when you can't access the iTunes store? Have you checked your connection to the network?
    Please be a little more specific

  • How do i stop an old apple ID and password prompt from always popping up on my phone during normal use ?

    How do i stop an old apple ID and password prompt from popping up on my phone screen during normal operations ?

    How to change the Apple ID on my iOS Device
    Settings > iTunes & App stores.
    Tap your Apple ID, sign out then sign back in with new AppleID.
    Settings > Facetime.
    Tap your Apple ID, sign out then sign back in with new AppleID.
    Settings > Messages.
    Turn off iMessages, wait 10 seconds, then turn it back on.  Go to 'Receive messages at' and then tap your Apple ID.  Sign out of the old ID, then sign in with new Apple ID.
    Settings > iCloud.
    Delete the account (make sure to KEEP the information on your phone), then turn it back on with new Apple ID.
    Also, delete any apps that were downloaded with the 'old' Apple ID, then reinstall them with your 'new' ID.

  • How to get the values of all elements and sub elements from  following xml

    how to get the values of all elements and sub elements from following xml...
    <?xml version="1.0" encoding="UTF-8" ?>
    <List_AML_Finacle xmlns="http://3i-infotech.com/Cust_AML_Finacle.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://3i-infotech.com/Cust_AML_Finacle.xsd List_AML_Finacle.xsd">
    <TransactionID>TransactionID</TransactionID>
    <Match>
    <Src_Matched_Field>Src_Matched_Field</Src_Matched_Field>
    <List_Matched_Field>
    <FSFM_Matches>
    <NUMBER>NUMBER</NUMBER>
    <TERROR>TERROR</TERROR>
    <TU>TU</TU>
    <NAMEU>NAMEU</NAMEU>
    <DESCRIPT>DESCRIPT</DESCRIPT>
    <KODCR>KODCR</KODCR>
    <KODCN>KODCN</KODCN>
    <AMR>AMR</AMR>
    <ADDRESS>ADDRESS</ADDRESS>
    <SD>SD</SD>
    <RG>RG</RG>
    <ND>ND</ND>
    <VD>VD</VD>
    <GR>GR</GR>
    <YR>YR</YR>
    <MR>MR</MR>
    <CB_DATE>CB_DATE</CB_DATE>
    <CE_DATE>CE_DATE</CE_DATE>
    <DIRECTOR>DIRECTOR</DIRECTOR>
    <FOUNDER>FOUNDER</FOUNDER>
    <TERRTYPE>TERRTYPE</TERRTYPE>
    </FSFM_Matches>
    <OfacMatchDetails>
    <UID>UID</UID>
    <TITLE>TITLE</TITLE>
    <SDNTYPE>SDNTYPE</SDNTYPE>
    <REMARKS>REMARKS</REMARKS>
    <ID_UID>ID_UID</ID_UID>
    <IDTYPE>IDTYPE</IDTYPE>
    <IDNUMBER>IDNUMBER</IDNUMBER>
    <IDCOUNTRY>IDCOUNTRY</IDCOUNTRY>
    <ISSUEDATE>ISSUEDATE</ISSUEDATE>
    <EXPIRATIONDATE>EXPIRATIONDATE</EXPIRATIONDATE>
    <ADDRESS1>ADDRESS1</ADDRESS1>
    <ADDRESS2>ADDRESS2</ADDRESS2>
    <ADDRESS3>ADDRESS3</ADDRESS3>
    <CITY>CITY</CITY>
    <STATEORPROVINCE>STATEORPROVINCE</STATEORPROVINCE>
    <POSTALCODE>POSTALCODE</POSTALCODE>
    <COUNTRY>COUNTRY</COUNTRY>
    </OfacMatchDetails>
    </List_Matched_Field>
    </Match>
    </List_AML_Finacle>

    avoid multi post
    http://forum.java.sun.com/thread.jspa?threadID=5249519

  • I want to download an invoice template. How can I then fill in the template and place in a file?

    I want to download a template of an invoice. How can I then fill in the template and create a separate file?

    template in Word format? Excel? PDF? a little more information please.

  • How do I make new albums in photos and move picture from one album to another

    How do I make new albums in Photos and move photos from one album to another

    At the moment you can't - though it should be possible (if it makes it into the final release) in iOS 5 which will be available sometime in the Autumn. Photos cannot currently be moved between albums on the iPad.
    If  you sync separate folders from your computer you'll get an album for each of them on the iPad, and you have to sync all the folders/albums that you want together as only the most recent photo sync remains on the iPad (not including a folder in a sync is the way that you delete it from the iPad).

  • How to create a table with datatype blob and insert a pdf file (ravi)

    how to create a table with datatype blob and insert a pdf file,
    give me the explain asap
    1.create the table?
    2.insert the pdffiles into tables?
    3.how to view the files?
    Thanks & Regards
    ravikumar.k
    Edited by: 895044 on Dec 5, 2011 2:55 AM

    895044 wrote:
    how to create a table with datatype blob and insert a pdf file,
    give me the explain asapPerhaps you should read...
    {message:id=9360002}
    especially point 2.
    We're not just sitting here waiting to answer your question as quickly as possible for you.

  • How to disable Ctrl+W or Ctrl+C and Tab for .swf file

    How to disable Ctrl+W or Ctrl+C and Tab for .swf file
    ctrlKey = false; in KeyBoardEvents but how to apply it to the stage.

    Hello siva,
    Can I have what code return on your file..So that I can help some what
    Regards
    Kiran

  • How i can make forms read form nls and reports read from anather

    hi evrey one
    how i can make forms read form nls_lang and reports read from anather nls_lang ,
    I think that this property is found in the file format .ini,
    I forgot his name,
    Is there one has found this information,
    pleez share.
    thanks.

    At a minimum, the creation of the TcpClient will need to change its parameter to the name of server you want to use:
    TcpClient tClient = new TcpClient("gmail-smtp-in.l.google.com", 25);

  • HT1766 how do i print or save my imessages and text messages from my phone?

    how do i print or save my imessages and text messages from my iphone?

    When viewing the SMS messages, hit edit. You then have the opportunity to select whatever messages are needed. Forward these to your email or wherever you wish. You then have a text transcript in the body of an email that you can cut/copy/paste into Pages/Word/etc. for printing.

Maybe you are looking for

  • Convert to DNG not available in Bridge photo downloader?

    All of a sudden when I try to upload RAW photos from my Nikon D5100, "Convert to DNG" is shown in grey and will not let me select it in the photo downloader. I am having to use an outside converter instead. Also, the Camera Raw application is acting

  • Please Help, Setting up router and AirPort with port forwarding

    If anyone can help me it would be greatly appreciated. I have a DSL Router supplying my internet connection, this is then connected to my AirPort Base station and distributes my internet connection to my two Macs and my two iPhones. Everything is wor

  • Won't print from rear tray

    I have a Pixma MG6220. No matter what I do it won't print from the rear tray from a source on the web. I go to both the quick setting and main tab and select "rear tray." Still prints from cassette. I took out the paper from the cassette. Won't print

  • Mail shuts down when adding an attachment

    Afteer upgrading to Maveric I do have the following issue. When I open Mail and write an E-Mail and then add an attachment (no matter what file type). Mail shuts immediately down. When opening Mail again, luckily the written E-Mail is still there, bu

  • Installing Leopard on new iMac, installation just goes on and on...

    Hi there! Just bought a new iMac 24" with OS X 10.4 installed. I ordered the Leopard upgrade and installed it today, and experienced the already documented problem where login password is seemingly accepted but after a few seconds the login window ap