Hi Guys ,
i have a text file Content.txt which only contains the letter 'a'
i want to create a method which will read in all contents of the text document and store it in one string
i have been using
ArrayList<String> al = new ArrayList<String>(); int count =0; String inputtext = ""; Object[] StringElements; try{ FileInputStream fstream = new FileInputStream(InputFile); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) //loop through each line { // Print the content on the console al.add(count, strLine); // Store the text file in the string ++count; //incrament count } in.close();//Close the input stream StringElements = al.toArray(); //convert al array to object for (int a = 0; a < StringElements.length; a++) { inputtext += StringElements[a]; } } catch (Exception e) {//Catch exception if any System.out.println("Error: " + e.getMessage()); } return inputtext;
however when i print out the string i get 2 charcters 1 is a weired apostrophie dot thing and the letter a . i have checked the text file and only 'a' is in there See pic below
Do you guys know why i am getting this can you help