2013-06-23 52 views
1

我作出了我的世界......服務器和我有一個IllegalChar錯誤 這裏是日誌:java.nio.file.InvalidPathException

Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 4: file:FOO\server.properties 
    at sun.nio.fs.WindowsPathParser.normalize(Unknown Source) 
    at sun.nio.fs.WindowsPathParser.parse(Unknown Source) 
    at sun.nio.fs.WindowsPathParser.parse(Unknown Source) 
    at sun.nio.fs.WindowsPath.parse(Unknown Source) 
    at sun.nio.fs.WindowsFileSystem.getPath(Unknown Source) 
    at java.io.File.toPath(Unknown Source) 
    at com.sukkit.Info.loadProperties(FOO2.java:31) 
    at com.sukkit.Sukit.main(FOO.java:17) 

下面是server.properties文件:

generator-settings= 
allow-nether=true 
level-name=world 
enable-query=false      --FOURTH LINE 
allow-flight=false 
server-port=25565 
level-type=DEFAULT 
enable-rcon=false 
force-gamemode=false 
level-seed= 
server-ip= 
max-build-height=256 
spawn-npcs=true 
white-list=false 
spawn-animals=true 
hardcore=false 
texture-pack= 
online-mode=true 
pvp=true 
difficulty=1 
gamemode=0 
max-players=20 
spawn-monsters=true 
generate-structures=true 
view-distance=10 
motd=A Minecraft Server 

這裏是代碼:

File extFile = new File("server.properties");//create external file 
File inFile = new File(MAINFOO.getCodeBase(*/I HAVE CREATED THIS METHOD IN THE MAIN FOO CLASS*/)+"server.properties");//create internal file 
if (!extFile.exists()){ 
    OutputStream out; 
    try {out = new FileOutputStream(extFile); 
    Files.copy(inFile.toPath(), out); 
    } catch (FileNotFoundException e) { 
     Sukit.logE(e.toString()); 
     Sukit.getLogger().severe("ERROR: FILE IS CORRUPT...PLEASE REDOWNLOAD SUKIT"); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

這裏是MAINFOO.getCodeBase()方法:

public static String getCodeBase() { 
    String i = ClassLoader.getSystemResource("server.properties").toString(); 
    String is[] = i.split("server.properties"); 
    logD(is[0]); 
    return is[0]; 
} 

我沒有一個單一的:在我的屬性文件...幫助

+2

您似乎正在傳遞包含'file://'的文件路徑,這就是它失敗的原因,請在調用加載方法的位置添加代碼 –

+0

MAINFOO.getCodeBase(*/I HAVE CREATED這個方法在主FOO類* /)+「server.properties」)中? –

回答

2

的問題是不是文件。問題是文件名:file:FOO\server.properties。請注意,在索引4(字符5)處,您有一個:。相反,您應該只使用FOO\server.properties並省略file: