/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone {
int width;
int height;
List<char[]> map;
// pretend this is opening the real file, i just had to embed the data
// as a string because ideone.
// initialize
width = 0;
map = new ArrayList<char[]>();
while ((line = br.readLine()) != null) {
// optional: skip blank lines:
if (line.length() == 0)
continue;
// optional: verify that all lines are same length:
if (width == 0)
width = line.length();
else if (line.length() != width)
throw new Exception("lines are not all the same length."); // this is the only thing you really *need* to do:
map.add(line.toCharArray());
}
height = map.size(); // height is number of lines
System.
out.
printf("size: %d x %d\n", width, height
); for (int y = 0; y < height; ++ y) {
System.
out.
printf("%3d: ", y
); for (int x = 0; x < width; ++ x)
System.
out.
print(map.
get(y
)[x
]); }
}
"#########################\n" +
"#.......................#\n" +
"#......#................#\n" +
"########................#\n" +
"#......#................#\n" +
"#......#................#\n" +
"#......#................#\n" +
"#.######................#\n" +
"#.......................#\n" +
"#########################\n";
}