Solved

RandomAccessFile

Posted on 1998-11-15
4
210 Views
Last Modified: 2012-06-21

For RandomAccessFile, there is a writeUTF() method.  Is there just a plain writeString() or writeln() method, or a way to implement such a thing using RandomAccessFile (I like the ability to both read and write and append using the same stream, but in this case I just want to work with text files)?  There is a writeChars(), but it writes a string of chars, with a space between each, so it isn't quite what I'm looking for.

Thanks for any help!


ap9
0
Comment
Question by:ap9
  • 3
4 Comments
 
LVL 2

Expert Comment

by:vendrig
Comment Utility
Try writeBytes. A weird name, but you can give a String value for parameter and it's written as a string to file (so you can read it in your ASCII editor). Use "\n" for new line.
0
 

Author Comment

by:ap9
Comment Utility
Works great!  How can I credit you?  Can you repost that as an answer?


AP9
0
 
LVL 2

Accepted Solution

by:
vendrig earned 40 total points
Comment Utility
Comment reposted as answer:
Try writeBytes. A weird name, but you can give a String value for parameter and it's written as a string to file (so you can read it in your ASCII editor). Use "\n" for new line.
0
 
LVL 2

Expert Comment

by:vendrig
Comment Utility
Yeah, the name is real confusing. It took me some time to find that function ("but I don't want to write bytes, I want to write strings!";-) Good luck with it.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now