【发布时间】:2016-03-14 04:47:42
【问题描述】:
在 java 中,我必须获取图像的确切位置,该图像位于包内源目录下的文件夹(表情符号)中,但每当我调用时
String s= (Main.class.getResource("Emoticons\\happy.PNG")).getPath();
System.out.println(s);
emotable.put(emo[0], s);
它给了我这样的无效路径
/E:/oop/java/emoti/out/production/emoti/sample/Emoticons%5chappy.PNG
路径中没有任何名为 %5c 的内容。你能告诉我它为什么会出现或如何避免这种情况。
【问题讨论】:
标签: java class getresource