Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

read write component  RSS feed

 
Maki Jav
Ranch Hand
Posts: 449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is there a api for easy io reads/writes of byte streams, character streams and object streams?

Thanx in Advance,

Maki Jav
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Besides the java.io package? I suppose that depends on what you mean by "easy".
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.nio ?
 
Maki Jav
Ranch Hand
Posts: 449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

Sorry, I think I was not so clear earlier.

I was asking about a "third-party tool" that is built on java.io; just call
two three methods and your work is done. I want to save myself a bit code
that is all.
Java io is not that difficult.

Actually, what I require is an api in which save() delete() remove() etc are there. It saves data, say, in an ArrayList (after it has loaded prevoiusly saved collection from file and added the present data). It is able to remove some element from that collection etc...
The above goes for ObjectInputStream and ObjectOutputStream operations...

One question that just came to my mind is...
In jdk1.3 whenever we tried to write code this way...

FileInputStream fis =new FileInputStream ("myfile.obj");
ObjectInputStream ois=new ObjectInputStream(fis);

//If we declared this (for writing) before reading...
FileOutputStream fos =new FileOutputStream ("myfile.obj");
//We got a clean file as the fos had written to it already...So the file
//data was lost to us!
//Calling ois.readObject(); will give exceptions...

Now the question is...
Is this behaviour of fos still there?
Or has it been modified in later jdks?

I didnot termed it as problem because every language has a particular behaviour to it. I have seen strange behaviours in VB too.
So the programmer should know his language and
a warrior his sword!


Maybe I am clear about my inquires this time ...

Thanx in Advance!

Maki Jav
[ January 11, 2005: Message edited by: Maki Jav ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!