public static void deleteServer(int index) {
StringBuilder builder = new StringBuilder();
try
{
File file = new File(getFilePath());
BufferedReader reader = new BufferedReader(new FileReader(file));
int current = 0;
String line;
while ((line = reader.readLine()) != null) {
if (current != index)
builder.append(line);
current++;
}
FileWriter writer = new FileWriter(file);
writer.write(builder.toString());
writer.close();
reader.close();
}
catch (IOException e)
{
}
}
public static void deleteServer(int index) throws IOException {
BufferedReader reader = null;
PrintWriter writer = null;
try {
File file = new File(getFilePath());
String fileToWrite = "fileToWrite.txt";
reader = new BufferedReader(new FileReader(file));
writer = new PrintWriter(new FileWriter(fileToWrite));
int current = 0;
String line;
while ((line = reader.readLine()) != null) {
if (current != index) {
writer.println(line);
}
current++;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (writer != null) {
writer.close();
}
if (reader != null) {
reader.close();
}
}
}