InputStream closes with OutputStream?

Hello!
My problem is, that I need to close the Outputstream of a socket but not the InputStream.
I run this:
InputStream in = socket.getInputStream(); //works fine
socket.getOutputStream().close();      //I need that to fix a XMLparser problem
in = socket.getInputStream(); //throws a java.net.SocketException: Socket is closed. Why do they both close and not only the OutputStream? How could I fix it ? Can I reopen the InputStream of the socket somehow?
Thanx in advance
Kaethchen

well, but once it is shutdown, how can i get it back up? my client needs to shutdown after each write- But once i shut it down, the next write doesn't work.

Similar Messages

  • Does closing socket with close() also closes the outputStream and inputStre

    hi i have a simple query
    does closing socket with close() also closes the outputStream and inputStream() associated with the socket

    Yes.

  • JAVA Mapping: Convert the InputStream in  to OutputStream out

    Hi everybody,
    I'd like to code my first JAVA Mapping. For this I would just like to convert the InputStream in  to OutputStream out.
    This does not work:
    out = new FileOutputStream(new File(in));
    How has the code look like?
    Thanks, regards
    Mario

    Hi Mario.
    Do you want to convert input into output directly without doing any transformation?
    The way I've always used is to load the input document first:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(inputStream);
    After loading the document you can parse it's content with DOM API.
    Finally you create the transformed document and return it through outputstream:
    Document resultDoc = builder.newDocument();
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    DOMSource source = new DOMSource(resultDoc);
    StreamResult result = new StreamResult(outputStream);
    transformer.transform(source, result);
    If  you want to convert the input to output you can use:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(inputStream);
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(outputStream);
    transformer.transform(source, result);
    At this point, I think you will have the input into the output.
    Regards,
    Gari.

  • Firefox 4.0.1 closes with no error message. When I restore the session I get: Well, this is embarrassing. Firefox is having trouble recovering your windows and tabs. This is usually caused by a recently opened web page. What can I do?

    After opening certain websites, pogo, firefox 4.0.1 closes with no error message. When I restore the session I get: Well, this is embarrassing. Firefox is having trouble recovering your windows and tabs. This is usually caused by a recently opened web page.
    I have had this problem before and had to reinstall an earlier version of firefox.
    The error console has a long list of errors, many of them end with: does not implement nsIObserver. Is there a way to send the information on the error console to firefox support?
    Redownloading Firefox 4.0 will fix my problem until I either close firefox or turn off my computer. The problem recurs when I open firefox again.

    See:
    * http://kb.mozillazine.org/Firefox_crashes
    * https://support.mozilla.com/kb/Firefox+crashes
    It is also possible that there is a problem with the files [http://kb.mozillazine.org/sessionstore.js sessionstore.js] and sessionstore.bak in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder]
    Delete the files sessionstore.js and sessionstore.bak in the Firefox Profile Folder.
    * Help > Troubleshooting Information > Profile Directory: Open Containing Folder
    * http://kb.mozillazine.org/Profile_folder_-_Firefox
    * http://kb.mozillazine.org/sessionstore.js
    If you see files sessionstore-##.js with a number in the left part of the name like sessionstore-1.js then delete those as well.<br />
    Deleting sessionstore.js will cause App Tabs and Tab Groups to get lost, so you will have to create them again (make a note).
    See:
    * http://kb.mozillazine.org/Session_Restore

  • Can't update from version 3.6 to any newer versions? Firefox freezes or closes with any version past 3.6!

    Firefox freezes or closes with any version past 3.6! Have tried various suggestions from online support. I am using Windows XP Professional with all updates, Norton Security Suite, V5.1.0.2 updated. I am using Comcast. The following add-ons are installed in Firefox:DowloadHelper4.9.7, ExtendedCopyMenu(fixed version)1.6.1c and NoScript.
    I tried installing V8.1 and it would either freeze or close. I have tried opening it in safe mode but Firefox would not open.
    I have gone into the registry, removed all Mozilla and Firefox entries and reinstalled 8.1. Didn't make any difference. I really, really don't want to go back and start using IE.
    Is this an issue for anyone else or just my computer which is about a year old? Sure would appreciate any help.
    Regards,
    Paleo

    Thanks for your replies...
    jsd2:
    > What does it report for Build?
    Build 10A380
    a brody:
    > Backup your data first
    Done.
    > If you can't install the 10.6.8 combo update
    I can't... 10.6.1 says "Mac OS X update can't be installed on this disk. This volume does not meet the requirements of this update"  and any subsequent update attempt says it "requires version [before this one] or later"
              >  your driver software isn't compatible with 10.6.8
              Not sure how to check my driver
              > you have insufficient disk space
              I have 212 GB !
              > the permissions haven't been repaired  
              I had a problem recently with this (for my main user account only) and fixed it (I can't remember how!).
              But I should mention that I tried installing the 10.6.1 update from my other user accounts on this Mac
              with the same result.
              > or the PRAM battery needs replacing
              How do I check that? Is that the little watch-type battery that G3 Macs used to have?
    I should also add that I tried one of the malware scan sites mentioned on this forum and it returned 'no virus found'.

  • Every time i open an app it will close with in a few min and wont open at all if music is running in the backround. what can i do about this?

    every time i open an app it will close with in a few min and wont open at all if music is running in the backround. what can i do about this?

    See:
    iOS: Troubleshooting applications purchased from the App Store
    Contact the developer/go to their support site if only one app.
    Restore from backup. See:
    iOS: How to back up
    Restore to factory settings/new iPod

  • I had problem with my apps,they open for a while and closes with in seconds i cant acess them

    i had problem with my apps,they open for a while and closes with in seconds i cant acess them and i had this with all apss,expect apple apps

    Do you have a lot of apps? Did you use a lot of apps recently? If so, many of them may still be resident in memory even if you aren't currently using them. Double-tap the home key and you should see the app tray with a list of most recently used programs. Press and hold the icons in the tray and remove the ones you don't use often to remove them from memory. Powering off and then back on might also help.
    My wife's iPod does that sometimes, and it's usually because we run out of memory due to apps remaining in memory even when not used. The suggestion above is how we normally fix the problems.

  • Since I upgraded to os x maverick when I try to close with cmd + q from the drop-down menu the app store and I IMOVE reopen continuously.

    since I upgraded to os x maverick when I try to close with cmd + q from the drop-down menu the app store and I IMOVE reopen continuously.

    2 GB of RAM is pretty tight. I imagine that's at the very low end of what Yosemite wants, which could slow things down.
    As far as scroll direction, you can always change it in the trackpad settings. Unsure why it got flipped, but you can fix it in about 5 seconds. Choose "natural" (or don't) depending on how you like it.

  • Firefox freezes or closes with any version past 3.6!

    Firefox freezes or closes with any version past 3.6! Have tried various suggestions from online support. I am using Windows XP Pro with all updates, Comcast, Norton Security Suite, V5.1.0.2 updated. The only add-on that seems to work with newer versions is NoScript. I miss Colorful Tabs and Expended Copy Menu. Both those add-ons will freeze Firefox now. Sees like Firefox is going backwards instead of improving.
    I have gone into the registry, removed all Mozilla and Firefox entries and reinstalled 8.1. Didn't make any difference. Sometimes 8.1 will work for 3 or 4 sessions before freezing or not reloading. I then have to do a clean reinstall. I really, really don't want to go back and start using IE.
    Is this an issue for anyone else or just my computer which is about a year old? Sure would appreciate any help.
    Regards,
    Paleo

    Hi
    Well I have tried installing 8.1 without any add-ons and it will open once or twice. Then it will not open. I just reinstalled 3.6 to make this post. I have no issues with 3.6 but Mozilla has posted that this version will soon stop being supported. I can use 8.1 in safe mode with bookmarks enabled but not in regular mode!
    Thanks anyway for responding to my post.
    Regards,
    Paleo

  • Detect Safari browser close with the iPad 3

    Detect browser close with the iPad 3
    We have a web site being used on the iPad 3 through Safari.
    Our web site is used in a public setting and multiple users login to use it at different times. We have a questions about user account security.
    When a signed in user clicks the home button on the iPad , which minimize Safari and returns them to the home screen, can the user be signed out of our web site? We don’t want someone else to come and open the Safari browser and have access to the previous user's account information. Is there a client-side event that is triggered that we can handle so we can log the user out of the site?

    Is the iPad shared by everyone at this public setting?
    There is currently no way to handle different users on the iPad (or any iOS device).
    They are designed as single user devices.
    If your company is eligible for an Enterprise account, then you could write an app that could handle clearing user credentials but not in the current "normal" environment.

  • Keep getting error message and told "Indesign Needs to Close" with no other information

    Hi All - I recently upgraded to Indesign CC and have nothing but issues.  The program constantly errors out and says it "needs to close" with no other explanation.  I finally was able to finish my document by constantly restarting my computer and am now unable to export to PDF.  Just keep getting that error. After a dozen tries it did finally complete export but the file is absurdly huge and I am unable to drop it into my printers ftp:
    Any thoughts?

    See Replace Your Preferences and Remove minor corruption by exporting  for starters.

  • New installation oADE opens but closes with error when I click any item, not prompting to authorize

    I am on Windows xp have have lastest flash installed and have AdobeID
    Installation went as expected, but when I launch the program, any click on its item, causes the program to close with and error and want to report to MS.
    This is the text from the report
    EventType : clr20r3     P1 : digitaleditions.exe     P2 : 2.0.0.0    
    P3 : 5058357c     P4 : presentationcore     P5 : 3.0.0.0     P6 : 4f7e7142    
    P7 : 1710     P8 : dd     P9 : system.argumentoutofrange   
    I have run though all the recommended IE settings and cannot fix this behaviour.
    Some help someone?

    Try uninstalling and installing v1.7.2.  This works more reliably in various ways.  Several people have reported issues with V2.0 on XP.
    Version 1.7.2 is a little difficult to find,
    available on Adobe site for Windows and for Mac.
    http://helpx.adobe.com/digital-editions/kb/cant-install-digital-editio ns.html
    also for PC at http://www.tucows.com/preview/853736/Adobe-Digital-Edition-For-EBooks

  • Tab closes with no error msg when I click on "Allow". Msg: Firefox prevented this page from automatically redirecting to another page. I had to uncheck the Advance/General/Accessibility option for it to work. Why?

    Msg: Firefox prevented this page from automatically redirecting to another page. When I click on "Allow", The 2nd tab closes with no error msg This was Home Depot redirecting to CitiGroup.
    When I unchecked the Advance/General/Accessibility option to be notified of a "redirect" then things worked.
    Why did clicking on "Allow" not work?
    I posted step by step detail in the Trouble Shooting box below.

    Thank you for your answer. It does stop the redirection notices, but now I have no idea if potentially unsafe sites are redirecting me. I cannot figure out why it has only recently started to happen on my home page though, when nothing has changed on there and I've had it set to show redirections, ever since I set up Firefox.
    I guess I'll just have to make the decision as to whether I want to risk redirections or put up with the semi permanent notice.
    Thanks again mha007

  • Inputstream close() method

    Hi guys,
    I just have a small problem that i was hoping to have clarified.
    If I have a OutputStream fs:
    OutputStream fs;
    and then I create a printStream
    PrintWriter out = new PrintWriter( new OutputStreamWriter(fs));
    what happens if i call close() on the printWriter? Will I still be able to write from the outputStream?
    Is it okay to just call close() for the outputstream, and then don't call the close() for the printWriter?
    Thanks a lot
    Cuppo

    1. Where's your inputstream lol?
    Will I still be able to write from the outputStream?no. closing either will close the stream.

  • InputStream problem with Runtime.exec

    Dear all,
    I am writing a java application which is executing an external program (through threads). I am trying to read the output of that program while is in execution. Anyway i found out that InputStreamReader is not ready unless enough output of program is coming or the program exits.
    I simplified things writing the following small C program:
    main(){
    printf("Just a print\n");
    for(;;){} //Or anything that might keep program in execution
    So i am trying to find out why i cant get the output of this program unless it exits. Is this a problem with the underlying Stream? Is there any workaround?
    Thanks for any help.

    You are right. The C code is that of an external program that i am trying to execute and get its output. Actually i am working on a bigger program that it prints Directories recursively. To keep things simpler i used that simple C program to explain my problem.
    The code i am using is the following:
    /* WindowsExec.java */
    import java.io.*;
    public class WindowsExec
         response std_out,std_err;
         public WindowsExec(){
         try{
         String[] cmd = new String[]{"dark.exe"};
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(cmd);
    std_out = new response(proc.getInputStream(),System.out);          std_err = new response(proc.getErrorStream(),System.err);
    std_out.start();
         std_err.start();     
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
                   proc.destroy();
         } catch (Throwable t){
              t.printStackTrace();
    public static void main(String args[]){
              new WindowsExec();
    /* Response.java */
    import java.io.*;
    class response extends Thread
         InputStream is;
         PrintStream type;
         public response(InputStream is, PrintStream type){
              this.is = is;
              this.type = type;
         public void run(){
         try{
              InputStreamReader isr = new InputStreamReader(is);
    while(true){
    if(isr.ready()){
    System.out.println("Its ready!"); //HERE!!!
              break;     
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null){
    System.out.println(line);
                   isr.close();
                   is.close();
              catch (Exception ioe){
    ioe.printStackTrace();
    Notice that i am never getting isr.ready() = true!

Maybe you are looking for

  • Slideshow navigation buttons not working.

    Having had the slideshow navigation buttons that exist below my photos (back, pause, forward) working fine for some reason they are now coming up as question marks in Safari and error boxes in Firefox and Explorer. I have not made any changes to my s

  • Configuring SSL certificates on ALBPM Studio

    Hi, I am invoking a web service which is deployed on a web logic server which is a secure server and needs SSL certificates to communicate. I have the certificates but don't know how to configure it to my ALBPM Studio. Can I configure those to studio

  • IMac harddrive problem

    I've got a big problem with my iMac. About 4 weeks ago my Mac began to slow down and having all kind of weird hiccups. I did a disk check with the included disk utility and it gave a lot of errors and it couldn't be repaired, so I booted the disk uti

  • C6180 printer offline even though it's connected to the network.

    My c6180 printer won't connect with my computer. I went through the network settings on the printer itself and the settings on the printer itself show that it's connected to my router.  But when I try to send a document to the printer, my computer sh

  • Moving a layer's alpha channel into layer mask

    (CS3) I have a raster layer that has some semi-transparent pixels. I'd like to make the layer itself fully opaque, and move the contents of its alpha channel into a layer mask. How would I go about doing this? (If possible, merging the alpha channel