事实上,他找不到java.io.
识别import java.io.*;
import java.io.IOException;
,但当我尝试InputStream = this.getClass().getResourceAsStream("users.xml");
,我得到以下错误:
C:UserscpantaziuDocumentsNetBeansProjectsurlsrcmainjavacommkyongcommoncontrollerFailRegisterController.java:[120,12]找不到符号符号:变量InputStream.
Tools -> Java platform ses my jdk 1.6.
为什么我得到这个?
你必须分配一个引用变量:
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 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.