How to save console output as a .txt file

i am printing an image of binary and i want to print exactly this Image of String in .txt file.
is this possible to take ouput of console print data to save as .txt file

I can see that you already have created a writer that you called output.

So now, you just need to replace your print and println statements by output.print and output.println

yes i did that .
but i get this type of output

can u solved it .

Missing line break at the end of each line

Try to print ”\n“ at the end of each line

yes i did that . but i get same value and characters are changed .

Or use println instead of print

Please show your code

import processing.serial.*;
Serial myPort; 
PImage img;
PrintWriter output;
 String s;
 int i,j;

void setup()
  img = loadImage("vl.png");
  output = createWriter("danish.txt");
    myPort = new Serial(this, "COM6",115200);

void draw()


void function()
    for (int y=0; y<img.height; y++)
    for (int x=0; x<img.width; x++)

      int i= x+y*width;
      //String s = str(i);
           if ((i+1)%100 == 1) {
        //int c = s.charAt(0);
      if (img.pixels[i] == color(0,0,0))
      } else 
      String s = str(i);
       String[] q = splitTokens(s,"");
      String[] d = sort(q,q.length);



You missed an output.print("/n") line13 of your function called function.

Also please correctly format you code using ctrl+t on processing before posting it here.

if i am doing that i get this kind of output

In notepad:

Is the display of line breaks activated?

See menu View

Or try to look at your file with another program like WordPad or MS Word

till not working.
ok leave it and help me in another way
i want to create image like in my above code console window. example(apple image in binary)
this image is printing in console and when i want each row of this image sending to arduino but my string array is printing just like another example . tell me what is mistake in my code

Show your code please

Are you using some kind of LED grid? Which form?

i am not using led grid . it just 100 led’s which are connected in serial through arduino.

Are you using appropriate current limiting resistors?
An LED exploded in one of our labs at work with low voltages (5V); it can happen.
Always wear safety glasses when working on projects like this.



Typo there…

output.print("/n") will print /n

There are the different possible outputs I used testing:

        //Text file:                 // Output:
        //output.print("\r");        // CR
        //output.write("\r");        // CR 
        //output.print("\n");        // LF
        //output.write("\n");        // LF
        //output.write("\r\n");      // CRLF        
        //output.print("\r\n");      // CRLF
        //output.print();            // Error! Won't run.
        //output.println();          // CRLF
        //output.print("");          // no output!
        //output.write("");          // no ouput! 
        //output.print("/n");        // /n
        //output.print(":)");        // :)

I used Notepad++:
and select “View > Show Symbol > Show all Characters” to see the LF and CR characters (otherwise hidden from view).