Results 1 to 2 of 2
- 11-27-2011, 04:21 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
Creating a picture in java out of a txt file containing 0's and 1's
I need to make a 2D array out of the 0's and 1's in the file. The file is 25X25 in total so contains 625 characters in all, either 0 or 1.
This is the code I have so far:
import london.*;
public class Picture {
public static void main (String[] arg) {
EasyReader fileInput = new EasyReader("picture.txt");
EasyGraphics g = new EasyGraphics(30,30);
int cols = 30; // How many columns the array should have
int rows = 30; // How many rows the array should have
int[][] array2d = new int[rows][cols];
String strLine;
int xCounter = 0;
// Reading lines from the file using EasyReader
while ((strLine = fileInput.readLine()) != null) // fileInput.readLine() fills the variable strLine with a String value.
{
char[] stringArray= new char[42];
stringArray = strLine.toCharArray();
//display the array
for(int index=0; index < stringArray.length; index++) {
array2d[xcounter][index] = (int) stringArray[index] - 0x30;
}
xCounter++;
}
}
}
The EasyReader is just a class for input that inherits the BufferedReader class and is part of the "london" package. There is 1 error in compilation which says:
Picture.java:21: cannot find symbol
symbol : variable xcounter
location: class Picture
array2d[xcounter][index] = (int) stringArray[index] - 0x30;
^
Please can someone help me, I am literally pulling my hair out at this!
-
Re: Creating a picture in java out of a txt file containing 0's and 1's
xcounter != xCounter
Please note: the compiler is very unforgiving.
Similar Threads
-
Jar file making - picture problem
By amman in forum New To JavaReplies: 3Last Post: 05-06-2011, 12:14 PM -
Creating a file is Holding up java.
By rizowski in forum New To JavaReplies: 0Last Post: 04-20-2011, 05:47 PM -
Picture not showing when create JAR file
By kmckinley820 in forum New To JavaReplies: 4Last Post: 03-19-2011, 10:11 PM -
Creating Java bean From XML File in WebApplication
By ashokkumar in forum XMLReplies: 1Last Post: 10-22-2008, 05:02 PM -
Print a picture file
By oli001 in forum New To JavaReplies: 0Last Post: 11-26-2007, 01:40 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks