[英]How do I change IDEA's build folder from TEMP to something else?
Im trying to run: 我试图运行:
import java.applet.Applet;
import java.awt.*;
import java.net.URL;
public class img extends Applet
{
private Image img;
public void init()
{
img = null;
}
public void loadImage()
{
try
{
img = getImage(getCodeBase(), "winter.jpg");
System.out.println(img);
System.out.println(prepareImage(img, 300, 400, this));
}
catch(Exception e){}
System.out.println(getDocumentBase());
}
public void paint(Graphics g)
{
if (img == null)
loadImage();
g.drawImage(img, 0, 0, this);
}
}
But it doesn't find winter.jpg unless its in: file:/C:/Users/Admin/AppData/Local/Temp/ 但它找不到winter.jpg,除非它在:file:/ C:/ Users / Admin / AppData / Local / Temp /
System.out.println(getDocumentBase()); 的System.out.println(getDocumentBase()); returns: file:/C:/Users/Admin/AppData/Local/Temp/AppletPage1228891259548967526.html Instead of: C:/Users/Admin/Dropbox/dev/idea/Exam3/out/production/Exam3/ (where the .class files are located)
返回:file:/ C:/Users/Admin/AppData/Local/Temp/AppletPage1228891259548967526.html而不是:C:/ Users / Admin / Dropbox / dev / idea / Exam3 / out / production / Exam3 /(其中.class文件位于)
I'm using IntelliJ IDEA 12. 我正在使用IntelliJ IDEA 12。
I simply want to put my JPEGs in the Exam3 folder instead of the Temp folder. 我只想将我的JPEG放在Exam3文件夹而不是Temp文件夹中。 Any ideas?
有任何想法吗?
A workaround for loading the resource using getDocumentBase() you can get the URL by using the getResource of class which gets the resources relative to the class. 使用getDocumentBase()加载资源的变通方法,您可以使用类的getResource获取URL,该类获取相对于类的资源。
URL base = img.class.getResource("/data/winter.jpg");
Image img = ImageIO.read(base);
where data is a folder in the Exam3 folder in your case which contains this class file. 其中data是包含此类文件的Cases3文件夹中的文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.