我试图为Minecraft制作自定义发射器。我只是想从我自己的服务器下载主jar文件,没有别的。我反编译了一个文件(Launcher.java)并更改了#34; https://s3.amazonaws.com/Minecraft.Download/"的下载网址。对我自己。问题是,当我尝试用javac -classpath launcher.jar launcher.java重新编译它时会抛出5个错误:
launcher.java:313: error: reference to listFiles is ambiguous, both method listFiles(FilenameFilter) in File and method listFiles(FileFilter) in File match File[] directories = objectsDir.listFiles(DirectoryFileFilter.DIRECTORY);
launcher.java:317: error: reference to listFiles is ambiguous, both method listFiles(FilenameFilter) in File and method listFiles(FileFilter) in File match File[] files = directory.listFiles(FileFileFilter.FILE);
launcher.java:409: error: reference to listFiles is ambiguous, both method listFiles(FilenameFilter) in File and method listFiles(FileFilter) in File match File[] directories = virtualsDir.listFiles(DirectoryFileFilter.DIRECTORY);
launcher.java:441: error: reference to listFiles is ambiguous, both method listFiles(FilenameFilter) in File and method listFiles(FileFilter) in File match File[] versions = root.listFiles(DirectoryFileFilter.DIRECTORY);
launcher.java:445: error: reference to listFiles is ambiguous, both method listFiles(FilenameFilter) in File and method listFiles(FileFilter) in File match File[] files = version.listFiles(FileFilterUtils.and(new IOFileFilter[] { new PrefixFileFilter(version.getName() + "-natives-"), ageFilter }));
有没有办法做到这一点?不要介意我的写作风格,我试着整夜解决......
提前致谢。
答案 0 :(得分:1)
我自己想通了!我需要这样做:
import java.io.FileFilter;
然后修改
中的每个错误行File[] directories = objectsDir.listFiles(DirectoryFileFilter.DIRECTORY);
到此:
File[] directories = objectsDir.listFiles((FileFilter) DirectoryFileFilter.DIRECTORY);
现在一切正常。