Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 下载及;保存图形_Java_Image_Graphics_File Io_Javax.imageio - Fatal编程技术网

Java 下载及;保存图形

Java 下载及;保存图形,java,image,graphics,file-io,javax.imageio,Java,Image,Graphics,File Io,Javax.imageio,我在保存已加载的图片时遇到困难。图片保存在该程序所在的同一文件夹下。一个错误不断地出现。错误屏幕如下所示 错误 我的节目 如何正确下载和保存图像?我想您只需要指定类的路径 "C:\Program Files\Java\jdk1.6.0_22\bin\java.exe" -classpath <path to your class> loadapicture “C:\Program Files\Java\jdk1.6.0\u 22\bin\Java.exe”-类路径LoadApitu

我在保存已加载的图片时遇到困难。图片保存在该程序所在的同一文件夹下。一个错误不断地出现。错误屏幕如下所示

错误 我的节目
如何正确下载和保存图像?

我想您只需要指定类的路径

"C:\Program Files\Java\jdk1.6.0_22\bin\java.exe" -classpath <path to your class> loadapicture
“C:\Program Files\Java\jdk1.6.0\u 22\bin\Java.exe”-类路径LoadApiture

这并不能回答您的问题,但“LoadApiture”对于类来说是一个非常糟糕的名字。它更像是一个方法的名称。类应以大写字母开头。考虑一下:PictureLoader
import hsa.*;
import java.awt.*;
// Look at all of these extra imports needed for a picture file
import java.io.File;
import java.io.IOException;
import java.awt.image.*;
import javax.imageio.*;


public class loadapicture{
    public static void main(String[] args){
        Console con = new Console();

        // Variables need to open a picture file
        File tictactoefile;
        BufferedImage tictactoeimage;
        tictactoefile = null;
        tictactoeimage = null;

        // Now that the variables are created.. Time to load the picture into the variables
        // BTW  You need to load the file using a block called try/catch
        // Becuase if the file does not exist, you need to catch the error
        // You can use jpg, gif, and bmp

        try{
            // Trying to open the file and loading it
            tictactoefile = new File("");
            tictactoeimage = ImageIO.read( owin.jpeg);

        }catch(IOException e){
            // If the file is not found, this will happen
            con.println("ERROR... IMAGE FILE NOT FOUND"); 
        }


        con.drawImage(tictactoeimage, 100, 100, null);

        // Yes you can do all of this in a method
}
}
"C:\Program Files\Java\jdk1.6.0_22\bin\java.exe" -classpath <path to your class> loadapicture