[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Arrays

Posted on 1998-07-31
4
Medium Priority
?
161 Views
Last Modified: 2010-03-30
Is there anyway of sending a 2-d array to a file????
0
Comment
Question by:alanmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

650 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