Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Stream closed Exception  (Read 961 times)
0 Members and 1 Guest are viewing this topic.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Posted 2008-04-15 09:25:15 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
java.io.IOException: Stream closed
   at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:134)
   at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
   at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
   at java.io.BufferedInputStream.read(BufferedInputStream.java:313)
   at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2213)
   at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2226)
   at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2694)
   at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:761)
   at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277)
   at apk.GuardAI.directOpen(GuardAI.java:503)
   at apk.GuardAI.initialize(GuardAI.java:68)
   at apk.Agent00PK.<init>(Agent00PK.java:53)
   at apk.Agent00PK.main(Agent00PK.java:62)


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
/**
    * Open an AI using the class path only.
    * @param rec   The path of the resource.
    */

   private static void directOpen(String res)
   {
      try
      {
         ObjectInputStream is = new ObjectInputStream(new BufferedInputStream(Thread.currentThread().getContextClassLoader().getResourceAsStream(res)));
         qValues = (float[][][][][][]) is.readObject();
         is.close();
      }
      catch(Exception e) {e.printStackTrace();}
   }


Makes no sense to me. How is the stream closed immediately after I open it? Is this maybe because I'm not running from a JNLP right now? Also, I literally copy and pasted the InputStream creation from other places in my code that work with no issues. Any ideas why this one is so picky?

See my work:
OTC Software
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #1 - Posted 2008-04-15 11:56:49 »

Make sure your resource is correct.  If your resource is not constructed correctly, then the stream will close.

Offline ddyer

Senior Member


Medals: 5



« Reply #2 - Posted 2008-04-15 17:02:01 »

The bottom line is you'll never get rid of these completely.  Networking is complicated and the networking
layers of your OS are replete with "punt" conditions when there is no way to go forward with the prescribed
next step.  These kind of exceptions tend to happen in clusters, and more often when opening connections,
but they can happen at any time.    The best you can do is have a recovery plan which you have tested by
simulating random failures.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (19 views)
2014-09-12 09:08:26

Norakomi (54 views)
2014-09-10 13:57:51

TehJavaDev (63 views)
2014-09-10 06:39:09

Tekkerue (31 views)
2014-09-09 02:24:56

mitcheeb (53 views)
2014-09-08 06:06:29

BurntPizza (37 views)
2014-09-07 01:13:42

Longarmx (23 views)
2014-09-07 01:12:14

Longarmx (27 views)
2014-09-07 01:11:22

Longarmx (26 views)
2014-09-07 01:10:19

mitcheeb (34 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!