How to import links from a website?

Discussion in 'Plugin Development' started by AdityaTD, May 17, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    AdityaTD

    Hey guys Aditya here. I wanted to ask that how can I like update a Config file on every reload or restart so it syncs links from a website.?
     
  2. The best way is dropbox. It has a link that never changes (unless you rename/move/delete the file) even when you edit the file.
    You can download the file with this:
    Code:
    public File download(String url, File file) {
    try {
    Files.copy(new URL(url).openStream(), file, StandardCopyOption.REPLACE_EXISTING);
    return file;
    } catch (Exception e) { e.printStackTrace();
    return null;
    }
    }
    Example:
    Code:
    File config = download("https://www.dropbox.com/s/490prkhakpj4763/Test.java?dl=1",
    new File(getDataFolder(), "config.yml"));
     
  3. Offline

    mine-care

    @AdityaTD Dont forget to have a disable option for this feature else your plugin is not supported here :#
     
  4. Offline

    timtower Administrator Administrator Moderator

    @AdityaTD Or store the config in a database of course. Depends on what you need to store though how useful it would be.
     
Thread Status:
Not open for further replies.

Share This Page