In porting a Java program to Cocoa, I’ve come across the program using java.io.Reader and its subclasses. I’m not very familiar with what they do, so I can’t find a good replacement. Does anyone have any good recommendations on replacements or do I have to rewrite it?
In porting a Java program to Cocoa, I’ve come across the program using java.io.Reader
Share
Readers in Java are just “objectified” versions of block file read operations. In Objective C, you have access to the C library. That gives you fopen, fread, fclose, which are functions for reading raw data files block by block. Isn’t that all that’s really needed?
Then, if you need to read integers for example, you just cast the (void*) data blocks to (int*).
You could argue that a Java Reader is more abstract. Yes, there are subclasses for reading stuff from anywhere, not just files. But if you’re porting an existing program, you already know if the data source is a file or not.