?
Solved

Arrays

Posted on 1998-07-31
4
Medium Priority
?
162 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 30 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 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