Created
March 13, 2014 12:34
-
-
Save ucchyocean/9527607 to your computer and use it in GitHub Desktop.
/reload したときに、getResourceAsStream がnullになるかどうかの確認
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @author ucchy | |
* @license All Rights Reserved | |
* @copyright Copyright ucchy 2014 | |
*/ | |
package test; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import org.bukkit.plugin.java.JavaPlugin; | |
/** | |
* @author ucchy | |
*/ | |
public class TestPlugin2 extends JavaPlugin { | |
private static Class<? extends TestPlugin2> c; | |
/** | |
* @see org.bukkit.plugin.java.JavaPlugin#onEnable() | |
*/ | |
@Override | |
public void onEnable() { | |
if ( c == null ) { | |
c = this.getClass(); | |
} | |
InputStream is = c.getResourceAsStream("plugin.yml"); | |
BufferedReader r = new BufferedReader(new InputStreamReader(is)); | |
try { | |
while ( r.ready() ) { | |
System.out.println(r.readLine()); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} finally { | |
if ( r != null ) { | |
try { | |
r.close(); | |
} catch (IOException e) { | |
// do nothing. | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/reload してみたけど問題ないっすね。