Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by catssss, Apr 19, 2020.
how would I copy a file from internal to the outside
What do you mean with "internal" and "outside"? Which JAR file?
Can you elaborate on what you mean exactly?
A .jar file can be seen as a folder (don‘t know if it‘s compressed or not; if it is, you need an input-stream that de-compresses the file)
They are built on the ZIP format so they are compressed.
to read things on the inside of the jar file you need a stream or reader or whatever but how do I then take that and put it in the data folder sorry for the late reply
You can use Files#copy(InputStream, Path, StandardCopyOption) and ClassLoader#getResourceAsStream(String). But you can also use JavaPlugin#saveResource(String, boolean).
I have this
File CFile = Files.copy(in, this.getDataFolder(), CopyOption.COPY_ATTRIBUTES);
but the copy option doesn't have .something it only is copy option but the standardcopyoption does but when I try and use that it says that copy() is not applicable for the arguments standardcopyoption should I just cast it?
edit: I figured out my problem I now have Files.copy(getClass().getResourceAsStream("config.yml"), this.getDataFolder().toPath(), StandardCopyOption.REPLACE_EXISTING); but it still isn't working (I create the file to replace before it)
Just use JavaPlugin#saveResource(String, boolean)...
You have to use ClassLoader#getResourceAsStream(String). But consider using this: