# Issue with using PrintStream

**URL:** <https://discourse.processing.org/t/issue-with-using-printstream/35901>\
**Category:** Libraries\
**Created:** [March 22, 2022, 8:53pm UTC](https://discourse.processing.org/t/issue-with-using-printstream/35901 "2022-03-22T20:53:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![plantagenet](https://avatars.discourse-cdn.com/v4/letter/p/ea666f/32.png) [@plantagenet](https://discourse.processing.org/u/plantagenet)\
**Post date:** [March 22, 2022, 8:53pm UTC](https://discourse.processing.org/t/issue-with-using-printstream/35901/1 "2022-03-22T20:53:26Z")

</div>

I am trying to create a print stream class and store the errors/console in there, so when errors pop up they are stored in the printstream.

This is because I want to send any errors to a server when they appear. I have code working in eclipse for when an error appears it is stored in the print stream and sent to a server. However when I import it over using a library I made or just copying the code it doesn’t store the console in the print streams.

Does processing have an issue with print streams and byte stream array outputs?

An example of the code I am trying to use:

```auto
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
PrintStream printS = new PrintStream(byteArray);  
System.setErr(pst);
String tester = byteArray.toString(StandardCharsets.UTF_8);

```

---

<div class="post-metadata">

**Author:** ![th75](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@th75](https://discourse.processing.org/u/th75)\
**Post date:** [March 25, 2022, 11:12pm UTC](https://discourse.processing.org/t/issue-with-using-printstream/35901/2 "2022-03-25T23:12:53Z")

</div>

Hi,  
i don’t know if it help:

```auto
import java.io.PrintStream;
PrintStream pst;
void setup() {
  try { 
    pst = new PrintStream(sketchPath()+"log.txt");  
    System.setOut(pst);
    System.setErr(pst);
    System.out.println("System.out.print...");
  }
  catch(IOException e) {
  }
}

void draw() {
  box((100/0));
  exit();
}

```

if you run it in processing ide, you will get only the “System.out.println” in the txt file  
but if you compile and run you will get the ide console errors too
