How to get the byte[] size dynamically from the StreamMessage object

Hi all,
Using JMS, I am receiving the FDF file as StreamMessage from the queue and attaching it to the PDF file which is present in the local system.
For that, I have written the code as follows:
{color:#0000ff} Message msg = jmsTemplate.receive();
if(msg !=null && msg instanceof StreamMessage)
StreamMessage message = (StreamMessage) msg;{color}
{color:#ff6600}//hardcoded the byte array size value
{color}{color:#0000ff} byte[] bytes = new byte[{color:#ff0000}856{color}];
System.out.println("read msg="+message.readBytes(bytes));{color}
{color:#0000ff}PdfReader pdfreader = new PdfReader("D:\\Managing_Workflows_No_Comment.pdf");
PdfStamper stamp = new PdfStamper(pdfreader, new FileOutputStream("D:\\12345.pdf"));
FdfReader fdfreader = new FdfReader(bytes);
stamp.addComments(fdfreader);
{color} {color:#0000ff} stamp.close();
{color}{color:#000000}The above code is working fine except with the hardcoded of {color:#ff0000}byte array{color}{color:#ff0000} size value{color} which is given in {color:#ff0000}RED{color} in color.
Can anybody know, {color:#000000}*how to get the byte[] size dynamically from the StreamMessage*{color} object ?
Any help would be highly beneficial for me !!!!
Thanks and Regards,
Ganesh Kumar{color}

When you create your stream message you could add an property to your message, something like streamSize that would contain the number of bytes in your stream message. Then you could get this property from the message before declaring your array.
Tom

Similar Messages

  • How to get customer number and name from the SD document

    Hi All,
    Can you please let me know how to get Customer Number and Name from the SD Document?
    Thanks a lot....
    Anil

    Hi,
    It will be displayed in the SD (BIlling document) itself,  you clikc on the VF03. The customer name and number will also appear in the SO document also Tcode VA03
    regards,
    radhika
    Edited by: kolipara radhika on Jul 10, 2009 5:32 AM

  • I broke my iPhone 5 now using a 4 but don't know if or how to get my photos ect..from the 5 to the 4.can I do this and how plse help

    I broke my iPhone 5 now using a 4 but don't know if or how to get my photos ect..from the 5 to the 4.can I do this and how plse help

    Restore the backup of your iPhone 5 to your iPhone 4.  It will contain your camera roll photos. 
    To do this, first make sure the iPhone 4 is running the same or higher version of iOS as your iPhone 5 was.  If it isn't, you'll need to update it first.  Then, to restore the iCloud backup, you'll have to begin by erasing the iPhone 4.  If you have any newer data on the iPhone 4 that is not contained in the iPhone 5 backup, you'll need to save that first.  When you're ready, go to Settings>General>Reset, tap Erase All Content and Settings, then go through the set screens on the iPhone 4 and when given the option, choose Restore from iCloud backup and follow the prompt, choosing the backup of your iPhone 5 to restore to.  Be sure it is connected to wifi and your charger as it is restoring the backup.

  • How to get server data without reading from the socket stream?

    My socket client checks for server messages through
                while (isRunning) { //listen for server events
                    try {
                            Object o = readObject(socket); //wait for server message
                                tellListeners(socket, o);
                    } catch (Exception e) {
                        System.err.println("ERROR SocketClient: "+e);
                        e.printStackTrace();
                    try { sleep(1000); } catch (InterruptedException ie) { /* ignore */ }
                }//next client connectionwith readObject() being
        public Object readObject(Socket socket) throws ClassNotFoundException, IOException {
            Object result = null;
    System.out.println("readObject("+socket+") ...");
            if (socket != null && socket.isConnected()) {
    //            ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
                ObjectInputStream ois = new ObjectInputStream(new DataInputStream(socket.getInputStream()));
                try {
                    result = ois.readObject();
                } finally {
    //                socket.shutdownInput(); //closing of ois also closes socket!
        //            try { ois.close(); } catch (IOException ioe) { /* ignore */ }
            return result;
        }//readObject()Why does ois.readObject() block? I get problems with this as the main while loop (above) calls readObject() as it's the only way to get server messages. But if i want to implement a synchronous call in adition to this asynchronous architecture (call listeners), the readObject() call of the synchronous method comes to late as readObject() call of the main loop got called before and therefore also gets the result of the (later) synchronous call.
    I tried fideling around with some state variables, but that's ugly and probably not thread safe. I'm looking for another solution to check messages from the server without reading data from the stream. is this possible?

    A quick fix:
    - Add a response code at the beginning of each message returned from the server indicating if the message is a synchronous response or a callback (asynch);
    - Read all messages returned from the server in one thread and copy callback messages in a calback message queue and the synch responses in an synch responses queue;
    - Modify your synchronous invocation to retrieve the response from the responses queue instead from the socket. Read the callback messages from the corresponding queue instead from the socket.
    Also take a look at my website. I'm implementing an upgraded version of this idea.
    Catalin Merfu
    High Performance Java Networking
    http://www.accendia.com

  • How to get a Previously purchased app  from the App Store from a different account on the same computer?

    Recently had to replace my hard drive and some info has gone missing.  An App from the App Store for one.  How can I get it back now that I have a new account?  It wont let me sign on with the old one anymore.

    There's no need to create a new Apple ID just because the hard drive was replaced.
    Apps can only be re downloaded using the same Apple ID they were purchased with originally.
    You will have to re purchase the app using the new Apple ID.

  • How to get ringtones on my iphone4 from the music on my phone

    I make the ringtones and have to email them to myself but still don't know how to get them on my phone to be able to use.

    In case you don't know, ringtones use a different format then songs.  When you say "I make the ringtones", you need to have used an appropriate utility to do that.
    Assuming you did, then place those ringtones into the "Tones" section on iTunes on your computer, and sync your iPhone using iTunes, making sure you have the right rule set up so your tones get synced.

  • How to get my usernames to appear from the drop down box then password automatically put in?

    =( ugh...
    I used to have my settings where it remembered my user name from the drop down box - so I would just type the first letter of my user name and a drop down box would appear and I could just click on my user name for that particular site and my password would automatically fill in...
    I changed something the other night and can't remember what the heck I did... now it won't remember ANY user name OR password or like on face book it has my user name and password there automatically when I open up the log in face book page.
    So I would like to know if anyone knows what needs to be clicked and unclicked to make it so:
    I start typing my user name and the drop down box appears with user names and then my password automatically fills.. I DO NOT want all my user names and passwords already IN the forms when I first open the website... but for me to actually type in a letter and then it fills it... like it used to =(
    /cry
    why do I touch stuff?
    Anyway I hope someone can help me because I am going nuts trying to figure it out and think I'm goofing things up even more =/
    I have firefix 3.6.10

    Does this help?
    * http://kb.mozillazine.org/Password_only_filled_after_entering_user_name
    * Make sure that you not run Firefox in (permanent) [[Private Browsing]] mode
    * You enter Private Browsing mode if you select: Tools > Options > Privacy > History: Firefox will: "Never Remember History"
    * To see all History and Cookie settings, choose: Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    * Uncheck: [ ] "Automatically start Firefox in a private browsing session"

  • How to get Solaris 10 to boot from the CLI instead of the GUI?

    I tried searching on the site but was unable to get useful information from setting up Solaris such that it boots to command prompt instead of the GUI. Any help or suggestions would be appreciated.

    This will also work if you're running out-of-the box Solaris 10:
    svcadm disable graphical-login/cde-login:defaultThe problem with doing it that way is you then can't use your Solaris host to run SunRay thin clients. If you need to use the box as a SunRay server, you'll have to remove the reference to the :0 display somewhere in /etc/dt/config/Xconfig, IIRC.

  • My boyfriend purchased the new operating system for the mac book pro it was send to his email but we cant figure out how to get it and download it from the email

    how do we download our operating system purchase from our email it was sent to?

    You should have received a redemption code via email if you purchased Lion or Mountain Lion that would allow you to download the OS via the Mac App Store. If you purchased an earlier version it would come on discs, usually model-specific.
    Call back with some more information...
    Clinton
    MacBook Pro (15-inch Late 2011), OS Mavericks 10.9.4, 16GB Crucial RAM, Crucial M500 960GB SSD, 27” Apple Thunderbolt Display

  • How to get an UPDATABLE REF CURSOR from the STORED PROCEDURE

    using C# with
    ORACLE OLE DB version: 9.0.0.1
    ADO version: 2.7
    I returns a REF CURSOR from a stored procedure seems like:
    type TCursor is ref cursor;
    procedure test_out_cursor(p_Dummy in varchar, p_Cur out TCursor) is
    begin
         open p_Cur for select * from DUAL;
    end;
    I create an ADO Command object and set
    cmd.Properties["IRowsetChange"].Value = true;
    cmd.Properties["Updatability"].Value = 7;
    cmd.Properties["PLSQLRSet"].Value = 1;
    cmd.CommandText = "{CALL OXSYS.TEST.TEST_OUT_CURSOR(?)}";
    and I use a Recordset object to open it:
    rs.Open(cmd, Missing.Value,
    ADODB.CursorTypeEnum.adOpenStatic,
    ADODB.LockTypeEnum.adLockBatchOptimistic,
    (int) ADODB.CommandTypeEnum.adCmdText +
    (int) ADODB.ExecuteOptionEnum.adOptionUnspecified);
    The rs can be opened but can NOT be updated!
    I saved the recordset into a XML file and there's no
    rs:baseschema/rs:basetable/rs:basecolumn
    attributes for "s:AttributeType" element.
    Any one have idea about this?
    thanks very much

    It is not possible through ADO/OLEDB.
    Try ODP.NET currently in Beta, it is possible to update DataSet created with refcursors. You need to specify your custom SQL or SP to send update/insert/delete.
    As I remember there is a sample with ODP.NET Beta 1 just doing this.

  • How to get a disc to eject from the portable disc drive

    I have a CD in the disc drive and when I click on the reject it tells me that it has already ejected it and won't let me force eject either. 

    Without knowing the specific drive you are having problem with maybe some of the suggestions here will help.
    How force eject disc: Apple Support Communities
    Mac Mini: Eject DVD Apple Support Communities

  • How do I get the byte size of a server file before sending output via HTTP?

    I need to get the byte size of the file prior to streaming it. I can't seem to find a class/method I need. Basically, I have the path c:\\tomcat\\webapps\\documents\\sample.pdf in the servlet, I was hoping I could just use something from the File class but I couldn't find anything that seems to do the trick?
    thanks, in advance,
    Chuck

    maybe the source of the problem will help...I am trying to stream a PDF to IE and a blank page is being generated although all other file type work.
    I have found a lot of answers in the forum but no specific code examples. Here's what I have so far from picking through threads in here (can someone please show me how to get the byte size of the file so that I can assign it to the method response.setContentLength();?):
    String CONTENT_TYPE = " ";
         String target = " ";
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
         StringBuffer buf = new StringBuffer();
         HttpSession session = request.getSession();
         String file = request.getParameter("filename");
         target = file;
         int end = file.length();
    int beg = end-2;
         String type = file.substring(beg, end);
         if (type.equals("DOC")){
              CONTENT_TYPE = "application//vnd.msword";
         }else if (type.equals("XLS")){
              CONTENT_TYPE = "application//vnd.x-excel";
         }else if (type.equals("PPT")){
              CONTENT_TYPE = "application//vnd.ms-powerpoint";
         }else if (type.equals("PDF")){
              CONTENT_TYPE = "application//vnd.x-pdf";
         }else if (type.equals("MPP")){
              CONTENT_TYPE = "application//vnd.ms-project";
         }else if (type.equals("ZIP")){
              CONTENT_TYPE = "application//ZIP";
         }else if (type.equals("TXT")){
              CONTENT_TYPE = "text//plain";
         }else {
              CONTENT_TYPE = "text//html";
         //File f = new File(file);
         //int l = f.length();
         response.setContentLength(l); <----- supposedly this fixes my problem but I don't know how to get the byte szie of the file in an integer??
         // reset the response
         response.reset();
         response.setContentType(CONTENT_TYPE);
         try{
         // Get streams
         FileInputStream fileInputStream = new FileInputStream(target);
         ServletOutputStream servletOutputStream = response.getOutputStream();
         // Init byte count and array
         int bytesRead = 0;
         byte byteArray[] = new byte[4096];
         // Read in bytes through file stream, and write out through servlet stream
         while((bytesRead = fileInputStream.read(byteArray)) != -1) {
         servletOutputStream.write(byteArray, 0, bytesRead);
              servletOutputStream.flush();
         // Flush and close streams
         servletOutputStream.flush();
         servletOutputStream.close();
         fileInputStream.close();
         } catch (Exception e) {
         System.out.println(e.toString());

  • I tuned on IMatch, hated it, so turned it off. I want to get all my music back from the Cloud so that it sits locally on my hard drive. How do I do that?

    I tuned on IMatch, hated it, so turned it off. I want to get all my music back from the Cloud so that it sits locally on my hard drive. How do I do that?

    tina.rogers wrote:
    this seems to me to indicate that Match copied the library up into the cloud and it no longer physically exists on my HDD???
    No, this is not what iTunes Match does. When you enable the service it leaves all the original files right where they are and mirrors your library in the cloud by either matching tracks to tracks available on the iTune Store or uploading tracks to the cloud. The service does not delete files from your HDD.
    I am unsure what you mean by "library icon" or "itunes library file" but if you mean the iTunes Library.itl file the size of that file is irrelevant.
    Before you enabled the iTunes Match service approximately how many songs were in your iTunes library and where were they stored? On the internal HDD of the computer, or on an external? Also, do you have backups?

  • How to get password as string back from encrypted password byte array.

    Hi All,
    I am storing encrypted password and enc key in the database.(Code included encryptPassword method for encryption and validatePassword method for validating of password). Problem is that for some reason i need to show user's password to the user as a string as he/she entered. But i am not able to convert the encrypted password from D/B to original String.
    Tell me if any body know how to get the string password back from the encrypted password byte array after seeing my existing encryption code.
    //********* Code
    private Vector encryptPassword(byte[] arrPwd)
    try
    // parameter arrPwd is the password as entered by the user and to be encrypted.
    byte[] encPwd = null;
    byte[] key = null;
    /* Generate a key pair */
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN");
    SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
    keyGen.initialize(1024, random);
    KeyPair pair = keyGen.generateKeyPair();
    PrivateKey priv = pair.getPrivate();
    PublicKey pub = pair.getPublic();
    /* Create a Signature object and initialize it with the private key */
    Signature dsa = Signature.getInstance("SHA1withDSA", "SUN");
    dsa.initSign(priv);
    /* Update and sign the data */
    dsa.update(arrPwd, 0, 12);
    /* Now that all the data to be signed has been read in, generate a signature for it */
    encPwd = dsa.sign();
    /* Now realSig has the signed password*/
    key = pub.getEncoded();
    Vector vtrPwd = new Vector(2);
    vtrPwd.add(encPwd);
    vtrPwd.add(key);
    return vtrPwd;
    catch (Exception e)
    private boolean validatePassword(byte[] arrPwd,byte[] encPwd,byte[] key) throws RemoteException
    try
    // arrPwd is the byte array of password entered by user.
    // encPwd is the encrypted password retreived from D/B
    // key is the array of key through which the password was encrypted and stored.
    X509EncodedKeySpec KeySpec = new X509EncodedKeySpec(key);
    KeyFactory keyFactory = KeyFactory.getInstance("DSA", "SUN");
    PublicKey pubKey = keyFactory.generatePublic(KeySpec);
    /* Encrypt the user-entered password using the key*/
    Signature sig = Signature.getInstance("SHA1withDSA", "SUN");
    sig.initVerify(pubKey);
    /* Update and sign the password*/
    sig.update(arrPwd, 0, 12);
    return sig.verify(encPwd);
    catch (Exception e)
    Help upto any extent would be appreciated.
    Thanx
    Moti Singh

    Hi All,
    I am storing encrypted password and enc key in the
    database.(Code included encryptPassword method for
    encryption and validatePassword method for validating
    of password). Problem is that for some reason i need
    to show user's password to the user as a string as
    he/she entered. But i am not able to convert the
    encrypted password from D/B to original String.No, you are not encrypting the password in your code, you are merely signing it.
    Tell me if any body know how to get the string
    password back from the encrypted password byte array
    after seeing my existing encryption code.It is impossible to retrieve the original text out of a signature.
    You should read up on some encryption basics in order to understand the difference between signing and encrypting. Then you can find examples of how to encrypt something here: http://java.sun.com/j2se/1.4/docs/guide/security/jce/JCERefGuide.html.
    Actually there is one class specifically for keeping keys secure, KeyStore http://java.sun.com/j2se/1.4/docs/api/java/security/KeyStore.html
    - Daniel

  • How do you get the web application path from the servlet?

    I have created a web application which is installed in
    /webapps/myApplication
    /webapps/myApplication/data/users.xml
    /webapps/myApplication/WEB-INF/classes/myServlet
    How can you get the path to the "users.xml" file from the "myServlet" file?
    The code below doen's seem to return the xml file. anybody knows why?
    public class myServlet extends HttpServlet {
    public void doGet( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException
    File myXmlFile = new File("/data/users.xml");

    Try this..
    String FileName = getServletContext().getRealPath("\\data\\users.xml");
    File myXmlFile = new File(FileName);
    hope this helps..

Maybe you are looking for