I'm trying to define an array without any specific size but cannot seem to figure it out.
Any help is appreciated and any comments regarding my coding is awesome so I could fix that for future learning :) Also, the count variable seems to count 64 characters instead of the 27 in the txt file?
Thanks.
EDIT: FYI there is another class that contains some methods I'm currently working on (which is MapFunctions mentioned at the end of the code)
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;
public class MapMain {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String T;
System.out.print("What is the file dest?");
T=input.nextLine();
//String [][] map = new String[!][!];
InputStream is = null;
int i;
char c;
try{
// new input stream created
is = new FileInputStream(T);
System.out.println("Characters printed:");
int count;
count = 0;
// reads till the end of the stream
while((i=is.read())!=-1){
count=count+1;
c=(char)i;
// prints character
System.out.print(c);
for (int i = 0; i<array1.length;i++){
for (int j = 0; j<array1[i].length;j++){
array1[i][j]=c;
}
}
}
System.out.print("\n"+count+"\n");
}catch(Exception e){
// if any I/O error occurs
e.printStackTrace();
}finally{
}
MapFunctions ankosh = new MapFunctions();
}
}
ArrayList, which is a dynamically resizable array or aHashMapdepending on your needs