Example #1
0
 public static void storeImage(BufferedImage image, String s) {
   String ext;
   File f;
   try {
     ext = s.substring(s.lastIndexOf(".") + 1);
     f = new File(s);
     f.mkdirs();
   } catch (Exception e) {
     System.out.println(e);
     return;
   }
   if (!ext.equals("gif") && !ext.equals("jpg") && !ext.equals("png")) {
     System.out.println("Cannot write to file: Illegal extension " + ext);
     return;
   }
   try {
     ImageIO.write(image, ext, f);
   } catch (Exception e) {
     System.out.println(e);
   }
 }