How to make it so comments don't get delete in the config

Discussion in 'BungeeCord Plugin Development' started by Forbidden391, May 3, 2017.

  1. Ok, so I have being have an issue where when I ever I save a config the comments in the config get deleted.

    Config Manager:

    Thank you to everyone who helps or tries to help
  2. Photon


    Basically you need to use 2 FileStreams:
    Code (Text):
                // Stream to read from the default-file
                final InputStream in = AACAdditionPro.getInstance().getResource(file_name);
                // Stream to write into the newly created file
                final OutputStream out = new FileOutputStream(resourceFile);

                if(in != null)
                    // Write the content of the default file to the newly created file
                    ByteStreams.copy(in, out);
    The first stream tries to get the resource that is included in your .jar.
    The OutputStream writes into the file (declare the path you want to save your file in there)
    After that you copy all the received bytes from the input-stream over to the output stream if the input stream is not null, this will prevent several NPE errors to appear, e.g. if the file could not be created properly. Make sure that both files exist before you copy the bytes.