InputStream and OutputStream - Already opened for input

URL url = new URL("website.com");
        URLConnection urlc = url.openConnection();
        urlc.setDoOutput(true);
        urlc.setDoInput(true);
        urlc.setUseCaches(false);
// read something from a file
        BufferedReader reader = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
        while (reader.read() > 0) {
            // do something
        reader.close();
// write something to the same file
        DataOutputStream dos = new DataOutputStream(urlc.getOutputStream());
        dos.writeBytes("write something");
        dos.close();"java.io.IOException: Already opened for input:"
what is that supposed to mean? Doesn't "reader.close();" take care of that?
I can read the file and I can write to a file. But I can't do both one after another...
Why is that?

I just swapped the code
URL url = new URL("website.com");
        URLConnection urlc = url.openConnection();
        urlc.setDoOutput(true);
        urlc.setDoInput(true);
        urlc.setUseCaches(false);
// write something to the same file
        DataOutputStream dos = new DataOutputStream(urlc.getOutputStream());
        dos.writeBytes("write something");
        dos.close();
// read something from a file
        BufferedReader reader = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
        while (reader.read() > 0) {
            // do something
        reader.close();

Similar Messages

  • CUSTOMER_ADD_DATA_CS open for input in display mode

    Hello,
    I have activated this BADI succesfully, I am linking into my subscreen correctly however the fields are always open for input. Do I have to control this in my abap or is there some way you use I-activity in SET_DATA?
    Regards
    Fiona

    Hi Fiona,
    In method GET_TAXI_SCREEN specify the screen and a Z program to control the fields for input.
    Eg:
          E_SCREEN = '0100'.
          E_PROGRAM = 'ZBADI_CUS_ADD_DATA'.
          E_HEADERSCREEN_LAYOUT = 'V'.
    Create a new program ZBADI_CUS_ADD_DATA to control the display and additional functionality.
    Please specify the code as mentioned below based on the screen group assigned.
    Eg Code:
    MODULE status_0100 OUTPUT.
      IF sy-pfkey CA 'A'.
        IF sy-tcode EQ 'VD03' OR
           sy-tcode EQ 'XD03' OR
           sy-tcode EQ 'FD03'.
          LOOP AT SCREEN.
            IF screen-group1 EQ 'CUS'
              screen-input = 0.
              screen-output = 1.
              MODIFY SCREEN.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDIF.
    ENDMODULE.
    Revert back for any further clarification.
    Regards,
    Babul.

  • BSP table column not opening for input

    I know very little about BSP but have a problem to fix. We have a BSP which works in 4.6 but not in ECC6. The problem is that when a table line is selected one of the columns is supposed to open for input but is not doing so. In the View the table is defined as selectionmode = "singleselect" and onRowSelection = "MyEventRowSelection" - I'm not sure where to find that event and associated method. Can someone direct me to the likely area of this problem? Thanks.

    Hi Mike,
    To have an editable table, the fields of your table must be bound to a cell editor of type 'Input field'. Check if this is done.
    Then, you should bind the read_only property of each input field to the context attribute. Not the read only of the table. This way, you can bind different columns to different attributes and make selected columns only as editable etc. For each field in your table, you will have a cell editor. Do the binding for each cell editor, i,e each column.
    Regards,
    Nithya

  • HT4414 I downloaded Mac OS. Mavericks and now my laptop won't intall the program it's says disk error and I already open te utility and repaid the disk and still stuck on that intall screen wat can I do

    I downloaded Mac OS. Mavericks and now my laptop won't intall the program it's says disk error and I already open te utility and repaid the disk and still stuck on that intall screen wat can I do

    Why did you wipe the drive?
    Were you having problems?
    If you were those problem may be related to a failing hard drive and that is why the TM backup could be restored.
    In you topic header you say the system won't boot from the SL DVD, But it di for you to wipe the drive. Then it should again boot from the SL DVD.
    Insert the DVD and reboot, hold down the Option key and select the Optical drive, SL DVD, as the Boot source.

  • Are inputstream and outputstream independent of eachother ?

    <b><u>Code snippet 1) </u></b><br>
    ByteArrayInputStream inputPDFStream = (ByteArrayInputStream) <SOME INPUT STREAM OBJECT>;<br>
    byte [] bArray = new byte [inputPDFStream.available()];<br>
    //Reading into byte array.<br>
    inputPDFStream.read( bArray );<br>
    //Dumping byte array contents onto file system.<br>
    File file = new File("//exchange//EPP//template//test_PDF_OnPortal.pdf");<br>
    FileOutputStream os = new FileOutputStream(file);<br>
    os.write(bArray);<br>
    os.flush();<br>
    os.close();<br>
    //Closing input stream, after all operations have been performed.<br>
    <b>inputPDFStream.close();</b><br>
    <br>
    <b><u>Code snippet 2)</u></b><br>
    ByteArrayInputStream inputPDFStream = (ByteArrayInputStream)pdfObject.createPDF();<br>
    byte [] bArray = new byte [inputPDFStream.available()];<br>
    int iBytesRead = inputPDFStream.read( bArray );<br>
    /*************** change starts here ************/<br>
    //Closing input stream immediately after it has been read from.<br>
    <b>inputPDFStream.close();</b><br>
    /*************** change ends here ************/<br>
    File file = new File("//exchange//EPP//template//test_PDF_OnPortal.pdf");<br>
    FileOutputStream os = new FileOutputStream(file);<br>
    os.write(bArray);<br>
    os.flush();<br>
    os.close();<br>
    /*************** change starts here ************/<br>
    // commented this line of code and shifted it above.<br>
    <b>//inputPDFStream.close(); </b><br>
    /*************** change ends here ************/<br>
    <br><br>               
    <b><u>Questions -</u></b> <br>
    <br>
    1) Are inputstream and outputstream objects totally independent of eachother ?<br>
    2) Will the change in the position of the "inputstream.close()" method as shown above, affect the writing of the file to the file system ?
    In other words, will the outcome of an "FileOutputStream.write(), flush() or close()" depend on when the inputstream object is closed as seen in code snippet (2) ?<br>
    3) Assuming that the output buffer is flushed, will any data that you try to write using the OutputStream.write() method, be written to the outputstream target (whether a file, or response object), irrespective of whether the inputstream is active at that point of time ??<br>
    <br>
    Thanks,<br>
    Navneet.<br>
    Changes made by -

    Hey kaj...Do you have any idea about the "not normal"
    situations in which case the input and output streams
    might influence eachother ? ;)Those cases are when both streams comes from a resource which closes both streams when one of them is closed. It's very rare to see, but I've seen some socket implementations which does that.
    Kaj

  • How to keep the field open for input with error message in report program

    Hi,
      Need a help in solving the below issue.
    "How to keep the field open for input with error message in report program"
    Regards,
    C.Shasiraj.

    Hi...
    you have to use the event:
    <b>AT SELECTION-SCREEN ON <FIELD> EVENT.</b>
    u have to give an error message in this event.
    Consider the following <b>Example:</b>
    <b>PARAMETERS : NUMBER TYPE I.
    AT SELECTION-SCREEN ON NUMBER.
      IF NUMBER = 10.
        MESSAGE 'Number vakue is 10' TYPE 'E'.
      ENDIF.
    START-OF-SELECTION.
      WRITE NUMBER.
    </b>
    in this if u give the value of number = 10, it will not proceed further, if u give some other value other than 10 you will proceed further...
    Execute this program once u will understand....
    also Consider the following links :
    <b>Regarding events:</b>
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/79/34a237d9b511d1950e0000e8353423/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/79/34a23ad9b511d1950e0000e8353423/frameset.htm
    <b>Regarding messages:</b>
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/c5/aa575426ad11d2954d0000e8353423/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/c5/aa575426ad11d2954d0000e8353423/frameset.htm
    This is very useful.......
    Reward points if useful....
    Suresh....

  • All of a sudden my iphone stopped charging and you can't hear the music through my ihome iH150 when I connect it to the dock, what can I do to fix the ihome? The ihome does turn on and I already checked for dock possible problems and I don't see anything.

    all of a sudden my iphone stopped charging and you can't hear the music through my ihome iH150 when I connect it to the dock, what can I do to fix the ihome? The ihome does turn on and I already checked for dock possible problems and I don't see anything wrong.

    I also have to add that the right earbud only doesn't work on my phone while i'm listening to music. If I'm face timing it's okay. what the heck.

  • HELP! File already open for writing?

    I've got a file that has been Stuffed (using Stuffit) and now I'm trying to unstuff it and/or open it but get the "File is already open with write permission (-49)" error with an "OK". When I click OK, it stops doing what it was doing. But this file has not been opened for months. What do you think happened to this file prior to stuffing it? Could it have been open and renamed while it was still open? Is there a way that I can open this file? This is a file that can be very helpful with the reconstruction of the next year's edition. We're a printing company. Any input would be great.

    There are a multitude of possibilities as to how a file might get corrupted. Specifically with Stuffit is that older versions had a file limitation, i.e., about 2GB of the total to be compressed, but the user does not get any warning to this fact. You may want to check the support section of their website. Hopefully, there is an uncompressed backup else where.

  • Is there configuration to have message for users when a spec object is already open for edit?

    We are on v6111 and appreciate the warning message that tells the second user when two users have editted the same spec object and changes of the first have already been saved.  What we are coming up against is users who want to know that someone else has already opened the spec object for edit.  Is there a configation for this?  Users don't like being informed after they enter data that someone else already saved a different edit ... they would like the warning before they do the actual work because it feels like a wasted effort ... If warned up front, they can come back and do the data entry later.  We are trying to find the appropriate configuration option to put the warning message in the appropiate UX process/timing.  Thank you!

    Hi Beckie,
    Sorry, but there is no out-of-the-box configuration to show this type of message.
    Regards,
    Ron

  • Should OKP1 being all closed and only be opened for the current period ?

    Guyz,
    In OB52 (Financial closing period) , only "open period" being input on it. So, basically the closing period in OB52 is by opening the period provided to be posting.
    Then how about OKP1?
    It's provided to lock the actual period , actual transactions, or to lock the plan period or plan transactions..but the question is:
    a. Should it be all closed (ticked mark all transactions & all periods) except for the current period that is provided to be posting as period determined in OB52...For example, it is now June, then all periods & transactions other than June is being ticked mark.
    OR
    b. Should it be all opened except for the period that is being closed? For example, it is now June, so periods & transactions of period January to May are being ticked mark (closed).
    Which of the options is the best practice?
    Need your answers asap plz.... Thanking you ..

    Hello,
    For example in OB52, if you have opened for June, i.e.,
    06 of 2009 to 06 of 2009 (1st Period)
    In such case,
    In OKP1, you need to only untick June for all the months and close all remaining months (Untick June and tick all other months and transactions).
    Note that your planning activities for all the year must have been completed. Otherwise, you cannot enter the plan values.
    Regards,
    Ravi

  • My new windows 7 machine and firefox color defaults for input boxes are obscurring the input box on the google search page making google unusable

    Under Windows 7 Firefox looks quite different including the default blue for input to question boxes which are white on the xp machines. Normally this is not a problem. But on the Google web page the blue is so bold that nothing can be seen except for a very small portion of the characters (in red) extending below the input screen. This becomes miserable if you try to edit a search stmt or backspace to correct a spelling error. you are quickly lost and need to clear the cache and reload the page.
    This problem does not appear using Chrome or IE on the same machine. Nor is it a problem using Firefox 9.0.1 on two other home PC's running XP (there no input box obscures the answer). This seems to be a lot of work.

    That can be caused by the "Keystroke protection" in Comcast Constant Guard.<br />
    "Configure Anti-Keylogging Settings" -> disable
    *[[/questions/874709]]
    *[[/questions/870165]]

  • [RS232] how to use InputStream and OutputStream

    hi
    i am using javax.comm
    i get input and outputstream
                  try {
                   out  = serialPort.getOutputStream();
                            in    =serialPort.getInputStream();
                  } catch (IOException e) {
                        }but i can use only write(bytes[]) and read(bytes[])
    i would use println and readln .. how can i do that?
    thanks in advance, nik

    @OP: Maybe this thread is of use to you:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=698876

  • ITunes doesn't open and agreement page opens for a split second then leaves

    Hi well i posted this thread a while back but never got a response soo I though maybe if I post a new one you would see me, sorry if im a burden but I really need the help. Okay well i just uninstalled iTunes because I already had problems with it but now, I just got my iPod and installed the cd on my computer.Then I click on iTunes and the agreement page comes up for one split second then exits out.Well heres all my Inof.I have Norton Anti Virus 2005, Windows XP, Microsoft Firewall (off), i have service pack 2 for microsoft and all the necessary updates are downloaded. I didnt download the optional upgrades only the ones that said were needed. please help me.
    -Danny =]
    Sony Vaio   Windows XP   i like cs and itunes and warcraft ALOT =)

    HI danny!
    sorry you got no response last time. PPLE post and post and post and before you know it, your thread is buried six feet deep under other threads.
    Ok, so you described your problem to me. I think its a particular malware program thats going around and it causes exactly what you described. BUT, because you do have Nortan 2005, its QUITE possible that is the culprit. Norton and itunes dont play nice together. Norton thinks its a malicious program and blocks it from opening. Its a pain, i know, but First, try turning OFF norton before you launch iTunes and report back to me about what happens.
    Cheers,
    Rachyl

  • Logical system name in SLD for the R3 buss. system is not open for input.??

    Dear all,
    We are upgrading to PI 7.1  and have a problem in a scenarie  where PI is sending IDOC to R3.
    The problem is probably related to the fact that it is not possible to write a logical system  name in SLD for the R3 system. I can not read the logical system name for the R3 system into the Directory (adapter specific identifier), *because the logical system for  the R3 bussines system is not an input file??*. How can i enter the logcal system name so i avoid following error:
      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Call Adapter
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>XIAdapter</SAP:Category>
      <SAP:Code area="IDOC_ADAPTER">ATTRIBUTE_INV_RCV_SERV</SAP:Code>
      <SAP:P1 />
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:Stack>Receiver service cannot be converted into an ALE logical system</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Regards Ugur

    There are two ways....
    Option 1 : Go to the BS of ur R3 system in Integration Direction. Go to edit mode mode and select Properties -> Adapter Specific attributes - > enter the LS name and save...
    Option2 : You can use it from the mapping.... U either hard code/use from source the EDIDC40 section of ur mapping and the in ur IDOC receiver config select the option user
    Option ! is the best soln...All the IDOC to that R3 system will go the specified LS...
    regards,
    Arvind R

  • Converting string into inputstream and outputstream Jsch (ssh connection)

    hi,
    I'm not really sure if this is the place where i should ask this, but if it is so then tell me!
    So my problem is that everything works just fine with input output streams like in this code, but i need to change this input stream into string messadge(Which would work!!)
    The main problem is not that i can't change string to inputstream, but that when i use inputstream every commands works, and when i try to do the same with sting>inputstream this doesn't work...
    unfortunatelly newgrp server; or newgrp doesn't rerally work just frezzes :/
    anyway i solved the initial problem, because Jsch have two (probably more methods of sending info to unix server, but because there is no documentation htere no way to know :D)
    methods of sending info to server : exec and shell , the exec sends one command and only works with commands like date;ls... now the shell can easily send any type of command including newgrp server1, and everything works :)
    so we connect to the server(passw,user,host) then excecute commands, this code works perfectle but the commented code// doesn't work :
    JSch jsch=new JSch();
    String host=null;
    String user="me1234";
    host="super.server.co.uk";
    String passw="12345";
    Session session=jsch.getSession(user, host, 22);
    session.setPassword(passw);
    session.setConfig("StrictHostKeyChecking", "no");
    session.connect();
    Channel channel=session.openChannel("shell"); //the power of shell, if i use exec doesn't excecute newgrp...
    //String command = "newgrp xxxx;"; //this doesn't work ...
    //InputStream is = new ByteArrayInputStream(command.getBytes("UTF-8"));
    //channel.setInputStream(is);
    //then somehow printout the response from server...
    channel.setInputStream(System.in); // well instead of this I'd prefer channel.send(command);
    channel.setOutputStream(System.out);
    channel.connect();
    Edited by: 842778 on 14-Mar-2011 01:42

    You seem to be leaving out the newlines.

Maybe you are looking for

  • File not found question

    I'm an experienced web designer, but new to Dreamweaver CS4, and am having a problem with a fundamental task: when I export a table from FW to DW, then try to edit the table from DW, I keep getting the "File not found" message. I've performed this ta

  • Transport iPhoto from MacBook to MacBook Air?

    My daughter bought a new MacBook Air, and an Apple Genius transferred all of her files from the old computer (MacBook running Leopard) to the new one, but when she opened iPhoto, the titles of the photos were there, but the photos themselves were bla

  • Best way to create samples on the fly in sample editor

    If I highlight part of a region in the sample editor and want to make a copy of it to use as a sample in EXS24, what's the best way to make that copy so that the plugin effects applied to that larger track are present on the copy. I find that it I ju

  • Lightjet Print Sharpening

    I do all of my personal stuff on large format Epson inkjets. No problem there with Lightroom. Great output. For years I never take a camera to family events to avoid having to supply them...know what I mean. These guys want (for the most part) 4x6s 5

  • I am unable to upload a firefox version that is compatible with my OS 10.4.11. Please help!!!!

    The website to download the version that is compatible withmy OS 10.4.11 is Firefox 3.6, but for some reason i am unable to download that older version- nothing happends when i click on the site...please help!!!!