File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Copying Integer to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Copying Integer to a file" Watch "Copying Integer to a file" New topic

Copying Integer to a file

Vaibhav Singhl

Joined: Aug 18, 2010
Posts: 4

My problem is I am unable to write integer to file, it is using as unicode, Can someone help me with the problem.

Thanks in advance!!
Anayonkar Shivalkar

Joined: Dec 08, 2010
Posts: 1456

Hi Vaibhav Singhl,

First things first : Welcome to CodeRanch!

When you post codes in your posts, please UseCodeTags. You can still go and edit your post.

Further, I don't really understand why you require all those variables - c,d,e,f,c1,d1 and so on. An array of variables(with a sensible name) would be better.

That said, let's come to your issue. Integer is not being written to file.

I would advice two things:
1) Try to debug the code.
2) Please go through documentation of write(int) method of RandomAccessFile class. There you'll find what exactly it does. Also, documentation would also give you hints about how to write integer to file directly.

I hope this helps.

Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Vaibhav Singhl

Joined: Aug 18, 2010
Posts: 4
Thanks Anayonkar for the help,

It would be very helpful if you can help me with writeInt() method. I tried but I am unable to get it work.

Vaibhav Singhl

Joined: Aug 18, 2010
Posts: 4
Thanks for the help it worked though tried differently.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36453
Anayonkar Shivalkar wrote: . . . please UseCodeTags. . . . .
I see you have found the code button. Please don’t post such long lines; they are difficult to read on most screens. And avoid tabs for indentation; use spaces instead.
I agree. Here's the link:
subject: Copying Integer to a file
Similar Threads
"==" Question from Kathy's Book
Remove Duplicate Rows
variable problem
stream output to reader input?
How to compare each individual char of 2 string