Code example for File

Methods: getNamerenameTo

0
		p.reloadConfig();
	} 
	 
	public boolean moveFile(File ff){
		SurvivalGames.$("Moving outdated config file. "+f.getName());
		String name = ff.getName();
		File ff2 = new File(SurvivalGames.getPluginDataFolder(), getNextName(name, 0));
		return ff.renameTo(ff2);
	} 
	 
	public String getNextName(String name, int n){
		File ff = new File(SurvivalGames.getPluginDataFolder(), name+".old"+n);
		if(!ff.exists()){
			return ff.getName();
		} 
		else{ 
			return getNextName(name, n+1);
		} 
	} 
	 
	 
	public void reloadSpawns() { 
		spawns = YamlConfiguration.loadConfiguration(f);
		if(spawns.getInt("version", 0) != SPAWN_VERSION){
			moveFile(f);
			reloadSpawns(); 
		} 
		spawns.set("version", SPAWN_VERSION);
		saveSpawns(); 
	} 
 
	public void reloadSystem() { 
		system = YamlConfiguration.loadConfiguration(f2);
		if(system.getInt("version", 0) != SYSTEM_VERSION){
			moveFile(f2);
			reloadSystem(); 
		} 
		system.set("version", SYSTEM_VERSION);
		saveSystemConfig(); 
	} 
 
	public void reloadKits() { 
		kits = YamlConfiguration.loadConfiguration(f3);
		if(kits.getInt("version", 0) != KIT_VERSION){
			moveFile(f3);
			loadFile("kits.yml"); 
			reloadKits(); 
		} 
 
	} 
	 
	 
	public void reloadMessages() { 
		messages = YamlConfiguration.loadConfiguration(f4);
		if(messages.getInt("version", 0) != MESSAGE_VERSION){
			moveFile(f4);
			loadFile("messages.yml"); 
			reloadKits(); 
		} 
		messages.set("version", MESSAGE_VERSION);
		saveMessages(); 
	} 
	 
	public void reloadChest() { 
		chest = YamlConfiguration.loadConfiguration(f5);
		if(chest.getInt("version", 0) != CHEST_VERSION){
			moveFile(f5);
			loadFile("chest.yml"); 
			reloadKits(); 
		} 
	} 
 
 
 
 
 
	public void saveSystemConfig() { 
		try { 
			system.save(f2);
		} catch (IOException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} 
	} 
Contextual code suggestions in your IDE  Get Codota for Java