- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameUtil.java
More file actions
Latest commit
26 lines (20 loc) · 574 Bytes
/
Copy pathGameUtil.java
File metadata and controls
26 lines (20 loc) · 574 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
importjava.awt.Image;
importjava.awt.image.BufferedImage;
importjava.io.IOException;
importjava.net.URL;
importjavax.imageio.ImageIO;
publicclassGameUtil {
// 工具类最好将构造器私有化。
privateGameUtil() {
}
publicstaticImagegetImage(Stringpath) {
BufferedImagebi = null;
try {
URLu = GameUtil.class.getClassLoader().getResource(path);
bi = ImageIO.read(u);
} catch (IOExceptione) {
e.printStackTrace();
}
returnbi;
}
}