Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  StringBufferINputStream deprecated for StringReader  (Read 2297 times)
0 Members and 1 Guest are viewing this topic.
Offline blahblahblahh

JGO Coder

Medals: 1

« Posted 2006-06-12 16:22:35 »

Could someone please explain this to me? It's been bothering me for about 10 years now.

The only class that lets you get an InputStream out of a String has been deprecate in favour of a class that only gives you a Reader.

Yes, it's a reader out of a string, but ... its not an IS.

And practically every library on the planet [ * ] uses IS's ... IIRC partly because Sun encouraged everyone to. All data is expected to be provided as streams.

I wanted to clean up some code thats throwing out compiler warnings, and this turned out to be the main culprit. But ... some quick googling reveals World + Dog all using it despite deprecation, and all complaining that Sun hasn't yet provided an alternative.

I keep hoping there's some missing class (e.g. since 1.5) I've not yet noticed that fixes the problem. Suggestions?

[ * ] = that I come into contact with - most obvious / common ones are XML libs, but obviously I do an awful lot with networking so no surprise there. But every large data-handling lib I've seen uses streams because, well, that's the ONLY sensible way to do it, isn't it? Lets you have arbitrarily large datasets with constant mem usage?

malloc will be first against the wall when the revolution comes...
Offline kevglass

« JGO Spiffy Duke »

Medals: 319
Projects: 25
Exp: 22 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #1 - Posted 2006-06-12 16:34:48 »

Would something like (just typed, not compiled) do for UTF8:

public class ReaderInputStream extends InputStream {
    private Reader target;

    public ReaderInputStream(Reader reader) {
 = reader;

    public int read() throws IOException {


Offline swpalmer

JGO Coder

Exp: 12 years

Where's the Kaboom?

« Reply #2 - Posted 2006-06-15 01:50:07 »

Is it that big a deal?

new ByteArrayInputStream(x.getBytes())

works for me.  Of course supply a charset/encoding to the getBytes() call if needed.

Pages: [1]
  ignore  |  Print  

EgonOlsen (78 views)
2018-06-10 19:43:48

EgonOlsen (58 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (260 views)
2018-05-13 18:23:11

nelsongames (158 views)
2018-04-24 18:15:36

nelsongames (157 views)
2018-04-24 18:14:32

ivj94 (898 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (811 views)
2018-03-24 14:43:53

Solater (175 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!