Checking for characters in a .txt file. instead of numbers ? [need help]

Hey everyone,

I have a question. Basically I know how to read a .txt file for numbers and i know how to add a lets say a block in the position of a ‘1’ and nothing in the position of ‘0’ EXAMPLE BELOW.
1 1 1 1 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 1 1 1 1

My problem is, i don’t really want to read numbers all the time. i want to be able to make maps using symbols such as ‘#’.EXAMPLE BELOW

# # #

0 0 0 0

0 0 0 0

# # #

Does anyone know how to do this ?

Thanks

i guess when you are reading from the text, you are saving the information in a multidimensional array of integers, just use a string array and you’re done,

Keep in mind that ASCII is actually number values…

So when you type in your characters, you can read them as characters in the same way you deal with integers.

Far more efficient to store it as a String, if it doesn’t bother you too much.

Use BufferedReader:


BufferedReader reader = //... initialise BufferedReader
String line;

//put a loop here?

line = reader.readLine();
char[] characters = line.toCharArray();

doSomethingWithCharacters(characters);