So I am just figuring out methods to finish my java project and i am having trouble skipping over white space. I got pretty much all the methods working except this one. If anyone can help me understand how to get the FileInputStream to skip over whitespace, then I can finally finish this project. Just stuck on this one part. This purpose of this class(not finished just working on methods then cleaning it up) is to take in a file(ASCII text art) and "zoom in" by a perfect square. Thank you
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;
public class makeBiggerTesting {
public static void main(String[] args) {
String fileName = "";
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter fileName: ");
fileName = keyBoard.nextLine();
try {
int zoom = 9;
int i = (int) Math.sqrt((double) zoom);
//Scanner fileScan = new Scanner(fileName);
FileInputStream inputStream = new FileInputStream(fileName);
// while(inputStream.available() > 0) {
// char input = (char) inputStream.read();
// System.out.print((char) input);
//
// }
// System.out.println("");
while(inputStream.available() > 0) {
char input = (char) inputStream.read();
for(int row = 1; row <= i; row++) {
for(int col = 1; col <= i; col++) {
System.out.print((char) input);
}
System.out.println("");
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
this is what one of the file looks like:
@ @
output:
@@@ @@@
@@@ @@@
@@@ @@@
is what it is suppose to be. but i get
@@@ (Bunch of space)@@@
@@@ @@@
@@@ @@@
When i run the program it turns into a big mess so i think its also zooming the white space. I could be wrong though