[英]Netbeans cannot find java.io.InputStream
Actually, he cannot find java.io.实际上,他找不到java.io。
It recognizes import java.io.*; import java.io.IOException;
它识别import java.io.*; import java.io.IOException;
import java.io.*; import java.io.IOException;
but when I try InputStream = this.getClass().getResourceAsStream("users.xml");
但是当我尝试InputStream = this.getClass().getResourceAsStream("users.xml");
, i get the following error: ,我收到以下错误:
C:\Users\cpantaziu\Documents\NetBeansProjects\url\src\main\java\com\mkyong\common\controller\FailRegisterController.java:[120,12] cannot find symbol symbol: variable InputStream. C:\Users\cpantaziu\Documents\NetBeansProjects\url\src\main\java\com\mkyong\common\controller\FailRegisterController.java:[120,12] 找不到符号符号:变量 InputStream。
Tools -> Java Platforms ses my jdk 1.6.工具 -> Java 平台 ses 我的 jdk 1.6。
Why am I getting this?为什么我得到这个?
您必须分配一个参考变量 :
InputStream ref= this.getClass().getResourceAsStream("users.xml");
您必须命名一个变量:
InputStream is = this.getClas()...
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
/**
*
* @author mbarb
*/
public class LoadSave {
public static BufferedImage GetPlayerAtlas(){
BufferedImage img = null;
InputStream is =
LoadSave.class.getResourceAsStream("Res/player2.png");
try {
img = ImageIO.read(is);
} catch (IOException e) {
e.printStackTrace();
}//try catch .close()
return img;
}
}
I'm have the same issue here in the code above.我在上面的代码中遇到了同样的问题。
i just get this:我只是得到这个:
Exception in thread "main" java.lang.IllegalArgumentException: input == null!
at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1358)
at Utilities.LoadSave.GetPlayerAtlas(LoadSave.java:19)
at Entities.Player.loadAnimations(Player.java:102)
at Entities.Player.<init>(Player.java:29)
at com.mycompany.platformgame.Game.initClasses(Game.java:32)
at com.mycompany.platformgame.Game.<init>(Game.java:21)
at com.mycompany.platformgame.PlatformGame.main(PlatformGame.java:7)
Command execution failed.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.