Advertisement
m4tx

Xevuel BMPNG convert

Jul 25th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import javax.imageio.ImageIO;
  2. import java.awt.image.BufferedImage;
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. public class Xevuel {
  7.     public static void main(String args[]) {
  8.         if (args.length == 0) {
  9.             System.err.println("ERR: No file specified");
  10.             System.exit(-1);
  11.         }
  12.         if (!args[0].toLowerCase().endsWith(".bmp")) {
  13.             System.err.println("ERR: Filename doesn't end with .bmp");
  14.             System.exit(-1);
  15.         }
  16.        
  17.         try {
  18.             BufferedImage img = ImageIO.read(new File(args[0]));
  19.             ImageIO.write(img, "png", new File(args[0].substring(0, args[0].length()-4) + ".png"));
  20.         } catch (IOException e) {
  21.             e.printStackTrace();
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement