FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   loadStrings() into a 2D array of chars?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: loadStrings() into a 2D array of chars?  (Read 325 times)
adm


loadStrings() into a 2D array of chars?
« on: Feb 14th, 2005, 11:43am »

Hi,
 
I'd like to load the contents of a .txt file into a two dimensional array of chars. I don't think is is possible with splitStrings. Can anyone tell me how?
 
st33d

WWW Email
Re: loadStrings() into a 2D array of chars?
« Reply #1 on: Feb 14th, 2005, 9:03pm »

Code:

String myString = "stuff and nonsense";
char [] myarray = new char[myString.length()];
myString.getChars(0,myString.length(),myarray,0);
for (int i = 0; i < myarray.length; i++){
println (myarray[i]);
}

That's a 1d array for you. I'm not sure how it translates into two dimensions.
 
There's more String methods here:
 
http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html
 

I could murder a pint.
adm


Re: loadStrings() into a 2D array of chars?
« Reply #2 on: Feb 14th, 2005, 10:01pm »

thanks, thats just what i needed.
 
-Aaron
 
Pages: 1 

« Previous topic | Next topic »