473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

writing integer to file in java

hi,
pls help me by giving the correct syntax to write array of integer into the file.
Explain with me suitable code

Thanks in advance
Sep 18 '08 #1
2 11520
Himzi
9
You maye need something like this :

Expand|Select|Wrap|Line Numbers
  1.  
  2. File file= new File("numberfile");
  3. PrintStream pin = new PrintStream(new BufferedOutputStream(newFileOutputStream(file.toString(), true)),true);
  4. System.setOut(pin);
  5. for(i=0;i<arrsize;i++)
  6. {
  7.  System.out.println("the number  is "+arr[i]);
  8. }
  9.  
  10.  
Sep 18 '08 #2
Nepomuk
3,112 Expert 2GB
You may also want to use the )]Arrays.toString() method, which exists since Java 1.5:
Expand|Select|Wrap|Line Numbers
  1. import java.util.Arrays;
  2.  
  3. public class ArrayWriter {
  4.    public static void main(String[] args) {
  5.       int[] myArray = {2,463,324,86,3,1,87};
  6.       System.out.println(Arrays.toString(myArray);
  7.    }
  8. }
will print the array in a nice readable way. Of course, you can also write that into a file.

Greetings,
Nepomuk
Sep 18 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: SomeDude | last post by:
Hi, I have a question on file writing. I am not very experienced in Java programming. My hobby right now is to write an applet where 2 persons could play Go together (it is a board game). The...
48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
2
by: slickn_sly | last post by:
For some reason, I'm getting an error. It doesn't seem to be reading my "input.txt" file. I'm trying to read the "input.txt" file which consits of random integers and use insertion sort to sort...
5
by: rob | last post by:
hey every1, I've got alot of data to write out to file and it's all just 1's and 0's. It's all stored in 2 dimensional arrays of width 32 and varying height. At the moment it's all just...
2
by: simonc | last post by:
Is there an easy way of writing a number in 32 bit integer format into four bytes of a file? I am experimenting with FilePut but I can only make it work by defining a four byte array and doing some...
2
by: Luc The Perverse | last post by:
I am a Java programmer - but I have had some experience programming in C++ before (3 years on a job) I have need of an application or set of applications to do the following on a windows...
1
by: dodo1267 | last post by:
hi all i need a help in writing cpu simulator i will thank everybody who will guide me how to start doing that and explain this: Program conditionals (loops, if-then-else) are translated into...
12
by: Fozzi | last post by:
Hey all I have been working on a project which allows me to write to a file and retrieve from that file, but i having trouble with it These are my inputs: private int flightno; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.