# Select output of printWriter

**URL:** <https://discourse.processing.org/t/select-output-of-printwriter/7014>\
**Category:** Coding Questions\
**Created:** [December 30, 2018, 8:06am UTC](https://discourse.processing.org/t/select-output-of-printwriter/7014 "2018-12-30T08:06:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)\
**Post date:** [December 30, 2018, 8:06am UTC](https://discourse.processing.org/t/select-output-of-printwriter/7014/1 "2018-12-30T08:06:06Z")

</div>

hello! how can i save the printWriter object inside a custom folder?

`wr = createWriter("obj"+ index + "txt");`

i want to create a folder inside a sketch and save the files there.  
Thanks!

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [December 30, 2018, 10:54am UTC](https://discourse.processing.org/t/select-output-of-printwriter/7014/2 "2018-12-30T10:54:57Z")

</div>

you give a filename or a path & filename  
so actually if you make that sketch  
and pls. first save it…

```auto

PrintWriter output;
String s = "Hallo World";

void setup() {
  output = createWriter("data/mytext.txt");
}

void draw() {
}

void keyPressed() {
  output.println(s);
  output.flush(); // Writes the remaining data to the file
  output.close(); // Finishes the file
  exit(); // Stops the program
}

```

and you RUN it and press any key  
the (sub) directory and file is created.  
( tested linux RASPBIAN and processing 3.4 )
