Solved

Arrays

Posted on 1998-07-31
4
156 Views
Last Modified: 2010-03-30
Is there anyway of sending a 2-d array to a file????
0
Comment
Question by:alanmin
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
mjenkins earned 10 total points
ID: 1229801
There is really no direct support for two dimensional arrays in Java. What you are really dealing with is an array of arrays.

So to write the whole thing to a file, just iterate through the outside array and each of the contained arrays in order.
0
 

Author Comment

by:alanmin
ID: 1229802
What i really need to know though is how to send it to a file.
0
 
LVL 3

Expert Comment

by:mjenkins
ID: 1229803
You didn't specify what kind of array it is. Is it an array of
primative types, or object? In either case, you can use a DataOutputStream ans just iterate through the tow arrays:

for( int i= 0; i < array.length; i++ )
{
      for( int j = 0; j < array[i].length; j++ )
      {
            ostream.writeInt( array[i][j] );
      }
}
0
 

Author Comment

by:alanmin
ID: 1229804
got it sorted anyway ta!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

809 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