How can I use an Inputstream twice?

Hi,
I have to read a ServletInputStream more than one time. But how can I do this? I first tried to use mark() and reset() but that doesn't work. After that I tried to copy the InputStream into a byte[] with:
byte[] inByte = new byte[request.getContentLength()];
      InputStream sin = request.getInputStream();
      sin.read(inByte);
InputStream in = new ByteArrayInputStream(inByte);But if the InputStream of the request is too big, I could not read the whole stream (and the sin.available doesn't because its always 0).
Is there perhaps a class available where I can put my InputStream without parsing every single byte to a byte[] ?

Hi,
if I am trying to put the request.getInputStream into an InputSource the request inputStream will be read and thats just the same if I use the request.getInputStream directly twice.
InputSource inSource = new InputSource(request.getInputStream());Could I perhaps clone the InputStream in some way?
To save the Stream into a temp File is not an option because I would have to solve the issue to reade the proper file, if the Servlet would be hit 20x at the same time.
Has anyone perhaps another idea how I can solve my issue?
Edit: I think I try to transform my XML Stream to a DOM/SAX and build new stream based on this new object.
Edited by: Troilus on Oct 17, 2007 12:52 AM

Similar Messages

  • How can I use one photo twice in a slideshow

    I am in iPhoto '11 9.4.3 making a slideshow to send to iDVD for my mother-in-laws funeral next Wednesday.
    How can I use this one particular photo of her several times in the slide show.
    I have tried copy/past and that does not seem to work.
    Thanx in advance

    I would just duplicate the picture several times and keep inserting duplicates ...

  • How can i use a component twice in the same movie clip

    Excuse me am a beginner in this as2
    below is the script used:
    PeelIt is a component.
    /////////////////////////////////////////////////1st frame contains the below:
    PeelIt._visible = false;
    PeelIt.init();
    PeelIt.Peel();
    ///////////////////////////////////////////////// then on 2 different buttons:
    on (release){
        this._parent.PeelIt._visible = true;
        this._parent.PeelIt.Stick();
    and
    on (release){
        this._parent.PeelIt.Peel();
    1st problem: i need this component to work when the swf loads instead of (on release),
    2nd problem: i need to introduce several frames with different movieclips using the component, how can i do so.
    thank you

    use:
    PeelIt.init();
    PeelIt.Peel();PeelIt._visible = true;
    PeelIt.Stick();
    PeelIt.Peel();
    and just add the component to each movieclip.

  • How can I convert an InputStream to a FileInputStream ???

    How can I convert an InputStream to a FileInputStream ???

    Thanks for you reply, however, I am still stuck.
    I am trying to convert my application (which runs smoothly) to a signed applet. The following is the original (application) code:
    private void loadConfig() {
    String fileName = "resources/groupconfig";
    File name = new File(fileName);
    if(name.isFile()) {
    try {
         ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName));
         pAndGConfig = (PAGroupsConfig)in.readObject();
         in.close();
         return;
    } catch(ClassNotFoundException e) {
         System.err.println("++ERROR: "+e);
    } catch(IOException e) {
         System.err.println("++ERROR: "+e);
    System.out.println("Can't find file: " + fileName);
    Because all code and resources now reside in a Jar file (for the signed applet), I must use the following line to access the resources:
    InputStream is = this.getClass().getResourceAsStream(fileName);
    I then need to convert the 'InputStream' to 'ObjectInputStream' or 'FileInputStream' so that I can work with it.
    I would be very grateful if you could help shed some light on the matter - Cobram

  • How can I use the Rownum/Customized SQL query in a Mapping?

    Hi,
    * I need to use a Rownum for populating one of the target field? How to create a mapping with Rownum?
    * How can I use an Dual table in OWB mapping?
    * Can I write Customized SQL query in OWB? How can I achieve this in a Mapping?
    Thanks in Advance
    Kishan

    Hi Niels,
    As I'm sure you know, the conundrum is that Reports doesn't know how many total pages there will be in the report until it is all done formatting, which is too late for your needs. So, one classical solution to this problem is to run the report twice, storing the total number of pages in the database using a format trigger, and throwing away the output from the first run when you don't know the total number of pages.
    Alternatively, you could define a report layout so that the number of pages in the output is completely predictable based upon, say, the number of rows in the main query. E.g., set a limit of one, two, ... rows per page, and then you'll know how many pages there will be simply because you can count the rows in a separate query.
    Hope this helps...
    regards,
    Stewart

  • How can we use the SDXC PORT ?

    Hi,
    Im intending to buy a Macbook pro 15" and i wonder how can i use the SDXC to boot my future macbook.
    I heard there is out there some cards to make it boot faster. I am not talking here about sd camera cards.
    And do you think i made the right choice by choosing the 15" 2.2 ghz i7 ?
    Thank you

    fane_j wrote:
    There's only one way to make your "mac faster and use it every day"—replace the internal disk drive with an SSD, or replace the internal SSD with a bigger and faster SSD.
    Disk I/O has alwas been the main bottleneck of all computers. So you either make it occur faster or you reduce de times it needs to occur.
    In the "faster" section, the issues I have with SSDs are several:
    Their price still needs to go down way more. The cost per MB of SSD-based storage is still vastly greater than that of HDDs. Yes, if you compute in extreme environments like karting down Baja or skydiving off the Himalayas, a ruggedized SSD is great, but most of us mortals live in the safe confines of a homey office.
    The size of SSDs has to expand much more. Yes, they are inching up to the 500GB size, but HDDs are at 1TB and promise to break that barrier before the year is out.
    If you purchase your SSD preinstalled in your Mac, you will be paying a big premium, compared to marketplace SSDs, even those from the same maker but not Apple-branded. This also applies to RAM.
    If you put in a non-Apple-branded SSD, Lion will not enable TRIM support by default and you will have to go "under the hood" to enable it. Without TRIM, you will not get the full performance and durability benefit of an SSD.
    Might be me, but I prefer to stick with HDDs for now, just making sure they are of 7200RPM spindle speed.
    In the "reduce" section, must point out that Lion is a 64-bit beast. Meaning that all data structures are twice the size of previous 32-bit cats. Regardless of "minimum" specs, 4GB RAM is the new practical minimum and 8GB makes the fat cat much happier. But buying RAM from Apple is not a financially wise decision; an 8GB upgrade from reputable vendors can be had for around $40, in stark comparison to the $200 premium charged by the Apple store. For the same $200 or a bit less, you can get a 16GB upgrade instead, not officially sanctioned but that works just fine with the latest model Macs. In this case, I don't think the OP will need as much, but it is something to take under consideration. The extra RAM will drastically reduce the disk-based paging that the memory management carries out, thereby minimizing that bottleneck.

  • How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes?

    How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes? I wanted my teenager's AppleID to be different from mine so that she couldn't charge stuff to my AppleID, therefore I created me another one. Now when I go to Sync either device, it tells me that this IOS device can only be synced with one AppleID. Then I get a message to erase it, not going to do that, lol. If I logout as one ID and login as the other, will it still retain all synced information on the PC from the first IOS device? If I can just log in out of the AppleID, then I have no problem doing that as long as the synced apps, music, etc stays there for both. I am not trying to copy from one to the other, just want to make sure I have a backup for the UhOh times. If logging in and out on the same PC of multiple AppleIDs is acceptible then I need to be able to authorize the PC for both devices. Thanks for the help. I am new to the iOS world.

    "Method Three
    Create a separate iTunes library for each device. Note:It is important that you make a new iTunes Library file. Do not justmake a copy of your existing iTunes Library file. If iTunes is open,quit it.
    This one may work. I searched and searched on the website for something like this, I guess I just didn't search correctly, lol. I will give this a try later. My daughter is not be back for a few weekends, therefore I will have to try the Method 3 when she comes back for the weekend again. "
    I forgot to mention that she has a PC at her house that she also syncs to. Would this cause a problem. I am already getting that pop up saying that the iPod is synced to another library (even though she is signed in with her Apple ID to iTunes) and gives the pop up to Cancel, Erase & Sync, or Transfer Purchases. My question arose because she clicked on "Erase & Sync" by mistake when she plugged the iPod to her PC the first time. When the iPod was purchased and setup, it was synced to my PC first. When she went home, she hooked it up to her PC and then she erased it by accident. I was able to restore all the missing stuff yesterday using my PC. However, even after doing that it still told me the next time I hooked it up last night that the iPod was currently synced with a different library. Hopefully, you can help me understand all this. She wants to sync her iPod and also backup her iPod at both places. Both PCs have been authorised. Thanks

  • How can i use my account without the billing info, as i do not have a credit card. and my shipping and billing info is under US. i'm in singapore. how do i change this?

    how can i use my account without the billing info, as i do not have a credit card. and my shipping and billing info is under US. i'm in singapore. how do i change this?

    If you are just visiting Singapore, then leave the account as it is. If you have moved there, then view your account using the iTunes app on a Mac or PC and change the country/region to your current location and address. If you do not have a bank card, you can fund your account using iTunes gift cards if available in Singapore.

  • How can i use microsoft word on ipad 2

    how can i use the microsoft application on my ipad 2?

    The Pages app is also compatible with MS Word. Unlike some of the others mentioned, the document is actually stored on the iPad as opposed to 'the clouds'. Again, most of those mentioned are cut down versions of MS Word.
    Stand back and look at this constructively; do you need to regularly access to the document from more than one computer/device without the need to keep amending your document on your computer and sending it to your iPad? If so, Documente to Go etc may be the best choice.

  • How can I use the credit on my account instead of credit card to buy apps?

    I have a gift card credit on my account but when I want to buy an app it takes me to my credit card details. How can I use my credit on my account instead of credit card?

    You shouldn't have to put in a credit card, no, but from time to time the iTunes Store seems for some reason to try to insist on one. If just confirming your mailing address doesn't stop it from complaining, go here:
    http://www.apple.com/support/itunes/contact/
    and follow the instructions to report the issue to the iTunes Store.
    Regards.

  • How can i use one SQL statement to solve problem?

    How can i use one SQL statement to solve the question below?
    For a Table named A, there is a column named F(char type).
    Now select all the records where F like '%00' and update their F value to '%01'
    Just one SQL statement.Do not use PL/SQL block.
    How to do that?
    Thanks.

    What is the data volume for this table?
    Do you expect lots of rows to have '%00' as their value?
    Following two statements come to mind. Other experts would be able to provide better alternatives:
    If you have index on SUBSTR(f, 2):
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) || '01'
    WHERE  substr(f,
                  -2) = '00';If most of the rows have pattern '%00':
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) ||
               DECODE(SUBSTR(f,
                             -2),
                      '00',
                      '01',
                      SUBSTR(f,
                             -2));

  • How can i use one iCloud Photostream on 2 devices?

    Due to a bug (or feature) on iOS 8 i can't use the same icloud id on 2 iphones:
    https://discussions.apple.com/thread/6536998
    So how can i use ONE iCloud Photostream then on 2 devices?
    Also, on OSX i can define only one Photostream.
    So, how do you import pictures from 2 streams into iPhoto?
    Familyshare is not usefull as the pictures are not in Original-Filesize!

    Hi ..
    Yes. " iPhone 6 or 6 Plus.  iPad Air 2  or  iPad mini 3"
    Set up and use Apple Pay

  • HT204053 Dear Support Team, every time i tried to logon Icloud its gives me wrong user name or password and at the end it show me error " This Apple ID is valid but is not an ICloud Account" then how can i use one account for same Apple ID and ICloud???

    Dear Support Team,
    Every time i tried to logon Icloud its gives me wrong user name or password and at the end it show me error " This Apple ID is valid but is not an ICloud Account" then how can i use one account for same Apple ID and ICloud?
    Thanks

    It is not possible to create a new iCloud account using a Windows machine. You must create the account using a Mac (10.7.5 or more) or an IOS device (iPhone etc). Once that is done you can sign into and use the account on your Windows machine.

  • How can I use same account in 2 iphone with diff contact list?

    how can I use same account number but other all totally diff such as contact list, application, everything ..... I found that it's bad on IOS5.
    when I used IOS4 .. old verison, I can keep my phone in diff data. Afte upgrade IOS 5, it's bad. Even take photo, it can not focus zoom in and out.

    how can I use same account number but other all totally diff such as contact list, application, everything ..... I found that it's bad on IOS5.
    when I used IOS4 .. old verison, I can keep my phone in diff data. Afte upgrade IOS 5, it's bad. Even take photo, it can not focus zoom in and out.

  • How can i use my ipod on 2 computers without deleting my music

    how can i use my ipod on 2 computers without deleting my music on ipod?

    See here: Using iPhone, iPad, or iPod with multiple computers
    B-rock

Maybe you are looking for

  • IPod is not recognized by my computer's usb port and itunes

    Remove my ipod from the computer without ejecting it and now the ipod want turn on, it is not being recognized by my computer's usb port or itune.  I have reinstalled itune and still have the same problems.

  • Invoice payment fields

    Would you please help me locate the following fields: Invoice number Funding account name Funding account identifier Payment account Payee identifier Payee name Payment amount

  • Camera no longer working on iPad air

    Hi everyone I switched my ipad air on and for some reason the camera doesn't appear to be working ? When i open the camera app there is just a black screen. It allows me to swipe from video to photo, but nothing happens and i cannot press the picture

  • Pages OSX 5.0.1 right alignment won't space when you press space, Help!

    Hi guys, Pages 5.0.1 isnt showing a space when I press space. You know how it has a space when you type on the left, and the cursor moves over, not on the right UNTIL you type something after it, is there a way to fix this? --Dan

  • Ipv6, how to view eigrp Id

    Hi everybody How is everyone doing? Is there any command  to display eigrp 's id for ipv6? I googled it but could not find any command. thanks and have a great weekend