Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Sequence Input Stream  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi, when im trying to compile it. its notifying me Null Point Exception in thread main (java.lang.NullPointerException)
at java.io.SequenceInputStream.nextStream(Unknown source)
at java.io.SequenceInputStream.<init>(Unknown source)
at SequenceInputStreamDemo.main(SequenceInputStreamDemo.java:35).

This is the error im facing.
Can some one help me out please
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Laxmi Bhavisetti wrote:This is the error im facing.
Can some one help me out please


Well, I'm no expert on this particular class, but it seems to me that you're confusing everything by treating Files like Strings; they're not, and they never will be.
Why not just set up an Enumeration<FileInputStream> and populate it with Files? An awful lot easier (and, I suspect, the way the class was designed to be used).

However, simply put, I suspect that your try...catch clause is returning a null.

Winston

 
Sheriff
Posts: 23647
49
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:However, simply put, I suspect that your try...catch clause is returning a null.



Yes, that probably wasn't the best way to handle the case where bad data was encountered. The best way to handle it would be to just let the nextElement() method throw the IOException, but that way isn't available since Enumeration.nextElement() isn't allowed to throw any exceptions. (Except NoSuchElementException, which wouldn't be appropriate in this case.)

What I would do would be to throw some unchecked exception which wrapped the IOException. Let's see... what have we got to choose from under RuntimeException? Maybe IllegalArgumentException isn't a bad choice? We could create our own subclass of RuntimeException, which might be a good idea depending on how architected you wanted your system to be, but let's just go with IllegalArgumentException to demonstrate the general idea:


This still results in unexpected exceptions being thrown, but at least they are easier to understand then the obscure one that the existing code throws.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!