Solved FilenotfoundExpection

Discussion in 'Plugin Development' started by Creeoer, Dec 2, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Creeoer

    Can not wrap my head around this, why isn't the file found? It's looking in the correct directory according to the stack trace.

    Stacktrace:
    Code:
    Caused by: java.io.FileNotFoundException: plugins\BBBlocks\schematics\Houseºa .s
    chematic (The system cannot find the file specified)
            at java.io.FileInputStream.open(Native Method) ~[?:1.7.0_67]
            at java.io.FileInputStream.<init>(Unknown Source) ~[?:1.7.0_67]
            at com.sk89q.worldedit.schematic.MCEditSchematicFormat.load(MCEditSchema
    ticFormat.java:62) ~[?:?]
            at me.creeoer.bb.handlers.LandChecker.canPlayerPlaceSchematic(LandChecke
    r.java:43) ~[?:?]
            at me.creeoer.bb.main.PlayerListener.buildlingPlace(PlayerListener.java:
    171) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
    _67]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
    _67]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_67]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_67]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:292) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            ... 16 more
     
    


    Line of code associated with it:
    Code:java
    1. File schematicsave = new File(main.getDataFolder() + File.separator + "schematics" + File.separator + schematicname + ".schematic");
    2.  
    3. MCEditSchematicFormat.MCEDIT.load(schematicsave);
    4.  
    5. CuboidClipboard cc = CuboidClipboard.loadSchematic(schematicsave);



    What it looks like in the directory:
    Capture.PNG
     
  2. Offline

    TGRHavoc

    Creeoer
    Because you're calling the "schematic" variable "Houseºa " and not "House" so Java is trying to find a file named "Houseºa .schematic" which doesn't exist.
     
  3. Offline

    Creeoer

    @TG4Havor
    And where is that a coming from? It's not in the file constructor. I get the display name of an item which is the string I pass in, why would it add that a?
     
  4. Offline

    TGRHavoc

    Creeoer
    You items' name that you're using must be called that then...
     
  5. Offline

    SyTeck

    Are there any external codes processing the file name? If so please provide it.

    Seems really weird though, as far as I'm concerned you do not have any illegal characters in the name right?
     
  6. Offline

    Creeoer

    SyTeck
    I take the item's name, it's called House BB Block. BB Block is replaced with an empty string, so now I have House. That is here:
    Code:
        if(im.getDisplayName().contains("BB Block")){
                          //This prints
                         
                          Bukkit.broadcastMessage("yooo i contain bb block");
                          String building = im.getDisplayName().replace("BB Block", "");
                         
                     
                         
                           
                   
                           
                            if (land.canPlayerPlaceSchematic(building, player) == true) {
    Thus the filenotfound expection is then thrown at me. No illegal characters correct.
     
  7. Offline

    TGRHavoc

    Creeoer
    Try printing the value of "building" to make sure that the characters are, in fact, being replaced correctly. Also, make sure that you ".trim()" the builder to remove any whitespace at the end of the string.
     
  8. Offline

    Creeoer

    TGRHavoc
    Trimming did remove the whitespace, however when I broadcast it, it displays "House" , yet that odd looking a is still there.
     
  9. Offline

    TGRHavoc

    Creeoer
    Hmm.. Does the items' name contain any special characters (such as § for chat colours)?
     
  10. Offline

    Creeoer

    TGRHavoc
    Yes! It is possible that the formatting is still there? How would I replace it?
     
  11. Offline

    TGRHavoc

  12. Offline

    Creeoer

    TGRHavoc Thank you, problem solved.
     
  13. Offline

    TGRHavoc

    Creeoer
    No problem, glad I could help :)
     
Thread Status:
Not open for further replies.

Share This Page