0

In my Spring boot application, I receive String, now I want to save them as files in a specific directory.

How can I do so ?

I have gone through this, but it is receiving file and saving, but I want to write to those files.

I'm using this code, raw JAVA:

PrintWriter writer = null;
        try {
            writer = new PrintWriter("file.txt", "UTF_32");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        writer.println(data);
        writer.close();

But it not how everyone will probably want, take a look:

space in spring-error

Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86

1 Answers1

1

It looks like it's your character encoding, UTF_32.

Notepad does not support UTF_32, only ansi, UTF_8, UTF_16.

See:

Can Notepad read UTF-32?

ajames
  • 813
  • 8
  • 8