Solved

Arrays

Posted on 1998-07-31
4
158 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iterator/ListIterator approach 17 68
swing controls 2 37
Website checklist for browser compatibility? 2 57
How to fix  socket closed error 11 64
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

732 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