• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is there a cursor in java?

 
Costa lamona
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Do I hava to copy the data of file into StringBuilder or another file, in case, I want to append into the middle of file but not the end of it.

that is because I cannot find any cursor in java.

If I correct, why sun did not provide us with cursor

thanks
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15713
73
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to insert data in the middle of a file, this is what you need to do:

1. Copy the contents of the original file up to the point where you want to insert data into a new file.
2. Write the data you want to insert into the new file.
3. Copy the rest of the original file to the new file.

There is no "cursor" in Java. From which other programming language did you get this concept?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I can tell, it's already the hardware that cannot do this - there is no way that a harddisk could insert some bytes between some arbitrary other bytes with the filesystems I know.

If there is some language that provides this feature, it would be interesting to see how it's implemented...

Anyway, moving to our IO forum...
 
Costa lamona
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks

Actually I hardly can remember that C under windows have a file cursor which let you go into the middle of file, It can also done virtually, I mean that It may be just let you toy with file cursor and when you want to read or write, It do everything behind the sense.

Ilja Preuss said:

As far as I can tell, it's already the hardware that cannot do this - there is no way that a harddisk could insert some bytes between some arbitrary other bytes with the filesystems I know.

Yes of-course, how I did not think about that, thanks , because this add something to my way of thinking.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!