Note that there are some explanatory texts on larger screens.

plurals
  1. POPrint to file produces unwanted text
    text
    copied!<p>I have something like this:</p> <pre><code>private void myPrinter(int[] arr) throws IOException{ FileWriter outFile = new FileWriter("myFile.txt",true); PrintWriter out = new PrintWriter(outFile); //BufferedWriter out = new BufferedWriter(outFile); //PrintStream out=new PrintStream(outFile); for (int i=0;i&lt;arr.length;i++){ System.out.print(arr[i]+" "); out.print(arr[i]+" "); } System.out.println(); // out.newLine(); out.println(); //out.flush(); out.close(); } </code></pre> <p>When it prints an array with 100 elements it is fine. <strong>When it comes to print an array with more than 255 elements it produces something like ‱‰‱‱‱‱‰‰‱‱‰‱਍</strong> When I add <code>out.print(" "+arr[i]+" ");</code> i.e space in front of <code>arr[i]</code> it is fine. However, I do not need that extra space at the front and I don't understand why it is needed. This method is called in a for loop iterating around a 2D array. console prints it fine but in txt file is printed as shown above. The code that is method is called is as follows:</p> <pre><code> final int[] anArr=init(); for (int idz=0;idz&lt; z;idz++ ){ int[] toBe=new int[anArr.length]; System.arraycopy( anArr, 0, toBe, 0, anArr.length ); arr[z]=create(toBe); try { myPrinter(arr[z]); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>I tried adding a line before anything is printed and it works. However, when I later manually remove the line from the txt file and save, it turns back to the gibberish text. Is there something wrong with my txt configurations or something else?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload