How to load images from different path

Hi,
i'm triying to load an image using the next code:
String path="C:/images/tv_on.gif";
java.net.URL imgURL =new java.net.URL(path);
img=Toolkit.getDefaultToolkit().getImage(imgURL);
but when it is compiled it returns MalformedURLException.
the image is in my local directory so i've tryed to define
path="file:///C:/images/tv_on.gif";
becuase the port and the local host name aren't needed.
Anyway it does not work.
I don't know how to load an image that it is in a file in a different path from the mainclass path
CAN ANYONE HELP ME?

sorry to bother, similar like above, i tried many times on my computer to load a simple image in java application.. here's my code:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
public class View extends JFrame {
     private URL imageURL;
     private File file;
     private Image sourceImage;
     private String name, title, message;
     private int width, height;
    public static void main(String[] args) {
        System.out.println( "Hello Eros!!!" );
        View img = new View();
    public View() {
         name = "D:/shared/inputpic.gif";
         file = new File( name );
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        try {
            imageURL = new URL("http://www.google.com.my/images/logo_sm.gif" );
        } catch (MalformedURLException e) {
        if ( file == null ) {
            sourceImage = Toolkit.getDefaultToolkit().getImage( name );
            System.out.println( file );
        } else {
            sourceImage = toolkit.getImage( imageURL );
            System.out.println( file );
        width = sourceImage.getWidth( this );
        height = sourceImage.getHeight( this );
        System.out.println( "Pixel = " + width + "x" + height );
        if ( width * height == 1 ) {
            title = "Greetings";  // Shown in title bar of dialog box.
            if ( file == null ) {
                message = "Unable to load the file " + name;
            } else {
                message = "Unable to load the link " + imageURL;
            JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE);
}could anyone test this n give my the reason i couldnt even load the image

Similar Messages

  • How to load images from css file in JavaFX 8

    I have this css file which loads images in JavaFX 8 application:
    #pill-left {
        -fx-padding: 5;
         -fx-border-image-source: url("/com/dx57dc/images/left-btn.png");
        -fx-border-image-slice: 4 4 4 4 fill;
        -fx-border-image-width: 4 4 4 4;
        -fx-border-image-insets: 0;
        -fx-border-image-repeat: stretch;
         -fx-background-color: null !important;
    #pill-left:selected { -fx-border-image-source: url("/com/dx57dc/images/left-btn-selected.png"); }
    #pill-left .label {
        -fx-text-fill: #d3d3d3;
        -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.75) , 0, 0.0 , 0 , -1 );
    #pill-left:selected .label {
        /* -fx-text-fill: black; */
        -fx-text-fill: white;
        -fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
    #pill-center {
        -fx-padding: 5;
         -fx-border-image-source: url("/com/dx57dc/images/center-btn.png");
        -fx-border-image-slice: 4 4 4 4 fill;
        -fx-border-image-width: 4 4 4 4;
        -fx-border-image-insets: 0;
        -fx-border-image-repeat: stretch;
         -fx-background-color: null !important;
    #pill-center:selected { -fx-border-image-source: url("/com/dx57dc/images/center-btn-selected.png"); }
    #pill-center .label {
        -fx-text-fill: #d3d3d3;
         -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.75) , 0, 0.0 , 0 , -1 );
    #pill-center:selected .label {
        -fx-text-fill: black;
        -fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
    #pill-right {
        -fx-padding: 5;
        -fx-border-image-source: url("/com/dx57dc/images/right-btn.png");
        -fx-border-image-slice: 4 4 4 4 fill;
        -fx-border-image-width: 4 4 4 4;
        -fx-border-image-insets: 0;
         -fx-border-image-repeat: stretch;
        -fx-background-color: null !important;
    #pill-right:selected { -fx-border-image-source: url("/com/dx57dc/images/right-btn-selected.png"); }
    #pill-right .label {
         -fx-text-fill: #d3d3d3;
        -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.75) , 0, 0.0 , 0 , -1 );
    #pill-right:selected .label {
        -fx-text-fill: black;
        -fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
    The images are located at the Java package com.dx57dc.images
    In Java 7_25 this code works as expected but in JavaFX 8 b99 I get this error:
    ava.lang.NullPointerException
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:1129)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:1598)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1520)
    at com.sun.javafx.sg.prism.NGGroup.renderChildren(NGGroup.java:233)
    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:199)
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:1249)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:1598)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1520)
    at com.sun.javafx.sg.prism.NGGroup.renderChildren(NGGroup.java:233)
    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:199)
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:1249)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:1598)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1520)
    at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:99)
    at com.sun.javafx.tk.quantum.AbstractPainter.paintImpl(AbstractPainter.java:210)
    at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:95)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
    at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:129)
    at java.lang.Thread.run(Thread.java:724)
    D3D Vram Pool: 13,331,480 used (5.0%), 13,331,480 managed (5.0%), 268,435,456 total
    20 total resources being managed
    4 permanent resources (20.0%)
    1 resources locked (5.0%)
    7 resources contain interesting data (35.0%)
    0 resources disappeared (0.0%)
    D3D Vram Pool: 13,331,480 used (5.0%), 13,331,480 managed (5.0%), 268,435,456 total
    20 total resources being managed
    4 permanent resources (20.0%)
    1 resources locked (5.0%)
    7 resources contain interesting data (35.0%)
    0 resources disappeared (0.0%)
    D3D Vram Pool: 13,331,480 used (5.0%), 13,331,480 managed (5.0%), 268,435,456 total
    20 total resources being managed
    4 permanent resources (20.0%)
    1 resources locked (5.0%)
    7 resources contain interesting data (35.0%)
    0 resources disappeared (0.0%)
    What is the proper way to load images from css in Java 8?
    Ref
    How to load images from css file in JavaFX 8 - Stack Overflow

    There is nothing special to do - you execute the statement from your program just like any other SQL statement.  The only thing to be aware of are the privilege/permission issues:
    When loading from a file on a client computer:
    READ CLIENT FILE privilege is also required for the database user.
    Read privileges are required on the directory being read from.
    The allow_read_client_file database option must be enabled.
    The read_client_file secure feature must be enabled.
    Revoking these privileges is also the only way you can prevent a user from executing the statement.

  • How to load images from BLOB to javascript?

    hi, Guys:
    I need to load thumbnail images from BLOB to multiple markers' infowindow in Google map . I have implemented Google map in APEX. I load the data suchas text for every marker's infowindow from Oracle database table with PL/JSON, and infowindow works fine. Could anyone give me a suggestion or example so I know how to load images to javascript?
    Thanks a lot.
    Database: Oracle 11g R2
    APEX: APEX 4.1
    Thanks.
    Sam

    lxiscas wrote:
    hi, VC:
    Thanks for your kind reply. I need to render these images out of APEX session, actually in javascript that is related to Google map markers' infowindow.
    I checked the documents of APEX_UTIL.GET_BLOB_FILE_SRC, but my impression is I need to use it in APEX instead of javascript if my understanding is correct. I already implemented a procedure with PL/SQL to load images from a BLOB column in Oracle database. But the problem is, how can I pass it to javascript code out of APEX to javascript (I could pass text or number from APEX to javascript with PL/JSON though,But I assume that still google map will be within a valid apex session? if so you should be able to use the above api.
    Basically what this api does is generates a kind of url to each blob in the database, not sure how google api's deal with this though. Why don't you give it a try?
    The other option is to make your pl/sql procedure public and then you can generate the json to include the images urls such as:
         "employees" : [{
                   "firstName" : "John",
                   "lastName" : "Doe",
                   "imgSrc" : "http://somewhere/db_schema.your_download_proc?p_file=#ID#",
                   "firstName" : "Anna",
                   "lastName" : "Smith"
                   "imgSrc" : "http://somewhere/db_schema.your_download_proc?p_file=#ID#",
                   "firstName" : "Peter",
                   "lastName" : "Jones"
                   "imgSrc" : "http://somewhere/db_schema.your_download_proc?p_file=#ID#",
    }And then you can use this new attribute to populate the images in javascript using standard img tag
    See this tutorial http://docs.oracle.com/cd/E14373_01/appdev.32/e13363/up_dn_files.htm
    I did not find any method in PL/JSON to pass image object)? So far I only found example to load images from local files to javascript.Hmm..I don't think you should load image objects.
    Vikram

  • How to load images from client side when the swf is hosted on a server without uplaoding it to server?

    I'm trying to build a online image resize tool.
    problem i face are:
    1. I build a button that allow user to browse the file. Once
    file is selected, it doesnt show full path.
    2. lets say if it shows fullpath, but i try to load it into a
    movieclip, and it doesnt work because the swf file is located at
    the server and not the client's place.
    3. as far as i know, flash can only load images which is
    located in the same server or internet.
    4. if i use php, asp, cgi.. it can only allow me to 1st
    upload the image then resize later, but this is not wat i want.
    5. I need to 1st resize then upload later, because if i have
    100 and more photos taken from digicam, it's going to be very slow
    and heavy.
    What i have tested:
    1. upload "image3.jpg" into the same directory as the
    "viewer.swf", and it works.
    2. do not upload the swf to the server, but run locally from
    the user's computer and open "image3.jpg" and it works.
    3. upload the swf to the server and open "image3.jpg" from
    the user's computer and IT DOESN"T WORK!
    please help me out.
    Thanks~!

    use this php code.
    for flash php image prosses.
    flash file
    import flash.display.BitmapData;
    shaF.onPress = function() {
    output();
    function output() {
    snap = new BitmapData(mc._width, mc._height);
    snap.draw(mc);
    var pixels:Array = new Array();
    var w:Number = snap.width;
    var h:Number = snap.height;
    for (var a = 0; a<=w; a++) {
    for (var b = 0; b<=h; b++) {
    var tmp = snap.getPixel(a, b).toString(16);
    pixels.push(tmp);
    var output:LoadVars = new LoadVars();
    output.img = pixels.toString();
    output.height = h;
    output.width = w;
    output.send("show.php", "output", "POST");
    stop();
    PHP file (show.php)
    <?php
    $data = explode(",", $_POST['img']);
    $width = $_POST['width'];
    $height = $_POST['height'];
    $image=imagecreatetruecolor( $width ,$height );
    $background = imagecolorallocate( $image ,0 , 0 , 0 );
    //Copy pixels
    $i = 0;
    for($x=0; $x<=$width; $x++){
    for($y=0; $y<=$height; $y++){
    $int = hexdec($data[$i++]);
    $color = imagecolorallocate ($image, 0xFF & ($int
    >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int);
    imagesetpixel ( $image , $x , $y , $color );
    //$font = imageloadfont('arial.ttf');
    $font = 'arial.ttf';
    // $text_color = imagecolorallocate($image, 233, 14, 91);
    $black = imagecolorallocate($image, 0, 0, 0);
    //imagestring($image, $font, 5, 5, "A Simple Text String",
    $text_color);
    imagettftext($image, 12, 0, 10, 20, $black, $font, "A Simple
    Text String");
    //Output image and clean
    //header("Content-Type: image/png");
    imagepng($image,"finoy.png");
    imagedestroy( $image );
    ?>
    <html>
    <body>
    <img src="finoy.png" width="159" height="159" />
    </body>
    </html>

  • How to load images from the library (png)?

    This is my first time using the forum so sorry if it's not professionally set up. I am trying to make an inventory system and I'm trying to find a way to have a Slot (MovieClip) holding a child of probably another MovieClip witch will display the icon according to whatever is in that Slot... As soon as I figure out how to have a MovieClip display an image and then change that image by loading it from the library, I can finish the rest! So let me try to demonstrate:
    (Note: This is not actual code, it's just a demonstration of what I'm trying to accomplish)
    Item1 = Name: "HP Potion", Icon: "HP_Potion.png"
    Item2 = Name: "MP Potion", Icon: "MP_Potion.png"
    Item3 = Name: "Sword", Icon: "Sword.png"
    Item4 = Name: "Shield", Icon: "Shield.png"
    Slot1.nameField.text = Item1.Name //HP Potion
    Slot1.mc_img = Item1.Icon//HP_Potion.png
    ~Ok so what I am trying to do is see if there is a way to change what image the MovieClip displays, just by code. I don't want to put each individual picture in a frame on the MovieClip's timeline
    Sorry about not having any code, I've been working on it for a few hours, and I can't find anything online that doesn't say put it in a timeline.
    If you know how to do what I'm asking with a spritesheet instead of individual images, that's fine too! I'll just have to join all the images together

    Alright so let's get down to buisness... what I'm asking, is it impossible to make it simple? I can't just change the bitmap of the MovieClip. If you open up the MovieClip and view it's timeline, the image is a bitmap file withing that MovieClip so if you're able to manipulate other things of a MovieClip, you should be able to manipulate that too right? Such as "MovieClip.Bitmap" (I know that's not the actual property but could it be done?).

  • How to load data from different database

    Hi,
    My problem is how to load Foxpro 2.6/clipper data into oracle 8 with all its structure and data with SQL loader or other utility if any.
    And also how can i integrate existing forpro system into Oracle. i.e client will work on Foxpro application and we will only take its output(data files) on daily basis and convert it into Oracle 8.
    Please find any solution.
    Regards
    null

    You can also try to make up an ODBC connection to Foxpro and convert the data from foxpro to oracle using the COPY command (see docs on PL/SQL & OCA). I remember that foxpro/clipper are running on MS-DOS, so I don't know if you can establish an ODBC connection to oracle which can be used from the foxpro/clipper application to use it as a frontend for an oracle database.
    Regards, Kai
    null

  • How to load image from non-GUID system drive to GUID system drive.

    About five months ago I got a new Mac Mini. About a month later I upgraded the internal HDD myself with a faster larger model. I used a third party software to clone the image from the original drive to the new drive and everything went smoothly, or seemingly so. Apparently I had omitted setting the partition scheme for GUID (I didn't know at the time) when formatting the new drive but everything seemed to work wonderfully and has been for some time under Leopard. But Snow Leopard will not upgrade to the non-GUID system drive.
    I have tried (twice now) booting from the Snow Leopard DVD and using its disk utility to create an image of my system drive (compressed), reformat the drive for the GUID scheme, and then restore from the saved image. Every time I get:
    RESTORE FAILURE
    Not enough space on /dev/disk0s2 to restore
    I am restoring to a 320GB drive 270GB of system & data in that image (217GB compressed.) The first time I got this error I had only 5GB free on the drive so I freed up over 10% of space on it to try again but got the same result.

    As far as the free space, I am referring to the state of the system drive before creating the first image. It had 33GB free the second time because I had moved extra files off the system drive myself to see if it would allow image-creation/partition-for-GUID/restore-partition to work.
    Yes, during both tries the images were made in the (default) compressed state. I am already in process of trying the operation with compression off. Fingers crossed.

  • How to load images from client to oracle server

    Hi
    I want to load the image in oracle. when i tried to laod the iamge from my client(windows) to oracle server(linux)
    it is giving error. i wrotea pl/sql program to store the images in oracle database.
    but the server not reconzing the path of image wich is client. how to overcome this probelm. as iam new to oracle
    i dont know apex and DAD. can any help me with an example
    thak you

    In addition to Solomon, please read:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6894565006210, that explains (again) why servers can't see clients and points to an sqlldr example @ http://asktom.oracle.com/pls/asktom/f?p=100:11:2928066747837319::::P11_QUESTION_ID:624423639385

  • Flash CS6; AS3: How to load image from a link on one frame and addChild(image) on other?

    How can I addChild outside the frame of images loader function? When I try to addChild on the other frame of the same loader, I get an error.
    I need to download all my 10 images only ONE TIME and place it on the screen in the other frames (to the same movie Clip).
    Also I can only play this as3 coded frame once. I know how to add an array of images, but I only need to understand how to do it with one image.
    Here is my loader for one image..
       var shirt1 = String("https://static.topsport.lt/sites/all/themes/topsport2/files/images/marskineliai_png/215.pn g");
       var img1Request:URLRequest = new URLRequest(shirt1);
       var img1Loader:Loader = new Loader();
       img1Loader.load(img1Request);
       myMovieClip.removeChildAt(0);
       myMovieClip.addChild(img1Loader);

    Symbol 'Spinner', Layer 'AS', Frame 2, Line 1
    1120: Access of undefined property img1Loader.
    [FRAME1]
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.*;
    import flash.net.URLRequestHeader;
    import flash.net.URLRequestMethod;
    import flash.net.URLVariables;
    import flash.events.SecurityErrorEvent;
    function init(e:Event = null):void
        removeEventListener(Event.ADDED_TO_STAGE, init);
        var loader:URLLoader = new URLLoader();
        var request:URLRequest = new URLRequest("http://www.topsport.lt/front/Odds/affiliate/delfi");
      var acceptHeader:URLRequestHeader = new URLRequestHeader("Accept", "application/json");
      request.requestHeaders.push(acceptHeader);
      request.method = URLRequestMethod.POST;
        //request.url = _jsonPath;
        loader.addEventListener(Event.COMPLETE, onLoaderComplete);
      //loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
        loader.load(request);
      try {
                    loader.load(request);
                } catch (error:Error) {
                    trace("Unable to load requested document.");
    init();
    function onLoaderComplete(e:Event):void
        var loader:URLLoader = URLLoader(e.target);
        var jsonObject:Object = JSON.parse(loader.data);
      var marsk1 = String("https://static.topsport.lt/sites/all/themes/topsport2/files/images/marskineliai_png/215.pn g");
      var img1Request:URLRequest = new URLRequest(marsk1);
      var img1Loader:Loader = new Loader();
      img1Loader.load(img1Request);
      _2.removeChildAt(0);
      if(_2 != null)
      _2.smoothing = true;
      //    the addChild which works when on frame one
      //_2.addChild(img1Loader);
    [FRAME2]
      _2.addChild(img1Loader);
    p.s. I removed the unnecessary code like other movieClips. It works then addChild function is on frame one.
    I'm kind of new to as3. I started using it this month so sorry if it's the obvious mistake.
    How to make flash recognize the loader?

  • How to Load image from file

    Hi all
    I want input Image into Forms Igame from a file
    using file open methods
    what should i do
    i am test some code from oracle 10g Docs but facing an error ORA-06508
    i thing some thing is missing in configration file
    Need Help
    Waiting for reply
    Take care
    Qaiser Hassan Awan

    Hello,
    Use an image item and populate it with the Client_Read_Image_File Webutil function.
    Francois

  • How to load image from a folder to HTML page

    Hi frds,
    It's Very Urgent.
    I'm doing Visitor Management System Project.Regarding that,I get all personal details from Visitor and i used web cam for capture the visitor photo.That photo stored in folder.Actually what is my Question is?.How to fetch the photo from that folder even "Submit" button click.Is it any possible for fetch the photo which is captured as last photo.That means photo fetch by Time sequence.

    The photo is stored on the visitor's local computer?
    If this is the case, the only real way to get it to your server through a webpage is to use a file upload control. This means the user has to select the photo manually before he presses the submit button.
    Check out the "file" input field, which is a standard HTML control.
    It's Very Urgent.Some friendly advice, the next time do not mention this. People here do not care that your problem is urgent, in fact it will make them less likely to answer your question.

  • How to load images from file system and save in database

    Hello Fellows!
    I have a problem and try to explain:
    Plateform:
    Operating System: Windows 98, Form 6i and Oracle 8
    Table in the database
    Table:Emp_pic with columns i.e. (empno and pic type long raw)
    In forms, I have a data block which contain the columns of the emp_pic table and a control block which have a push button contains the trigger as follow, also attach PL/SQL library i.e. D2kWUTIL.PLL
    When-Button-Pressed (Trigger)
    Declare
    temp varchar2(400);
    Begin
    temp := win_api_dialog.open_file('Open File','d:\pic','*.tif',true,win_api.ofn_flag_default,false);
    read_image_file(temp,'tif','emp_pic.pic');
    end;
    The problem when I pressed the button it does not display open dialog box what is the wrong with the code or else.
    Thanks in advance
    (BASIT)

    What do you mean "it did not work"? You need to post more information, such as what errors you got.
    My guess is that it did work, but it ran on the middle tier, which is where Forms is running. Commands like that need more work to execute on the client.
    Go to the Forms area on OTN and download the Oracle9i Forms Samples. They have demos and source code to move files from the client to the server.
    Coming soon will be a utility called WebUtil which will make this even easier.
    Regards,
    Robin Zimmermann
    Forms Product Management

  • How do you load images from a Win7 machine to iPhone?

    Hi. How do you load images from a Windows 7 PC to an iPhone 4? I'd like to load the pictures to use as wallpapers. Thanks.

    You CANNOT transfer photos from your computer to your iPhone when connected to your computer as an external drive. This is for transferring photos and/or video from your iPhone's Camera Roll to your computer's hard drive ONLY.
    To transfer photos from your computer's hard drive to your iPhone, this is selected under the Photo's tab for your iPhone's sync preferences with iTunes followed by a sync.

  • How I can load images from Creative Cloud storage in photoshop plugin, created in Extension Builder 3 with use html5/css/js?

    How I can load images from Creative Cloud storage in photoshop plugin, created in Extension Builder 3 with use html5/css/js ?

    At this point there is no API for accessing the cloud storage outside Adobe's own closed loop.
    Mylenium

  • How do i load images from a folder?

    Hello everyone,
    Please can someone help me as i am stuck.
    I am trying to research loading images from a folder called /images/unknown (unknown is a customer number and is stored in a variable called customerNo).
    I feel that i will need to load the images into an array then display them to the screen with a viewer.
    Can anybody help me.
    Thanks in advance

    Welcome to the Sun forums.
    irknappers wrote:
    ...Please can someone help me as i am stuck.You might want to be more exact in future, about what you are stuck on.
    import javax.imageio.ImageIO;
    import java.io.FileFilter;
    import java.io.File;
    import javax.swing.JFileChooser;
    class LoadImages {
        public static void main(String[] args) {
            String[] suffixes = ImageIO.getReaderFileSuffixes();
            FileFilter fileFilter = new FileFilterType(suffixes);
            File directory = null;
            if (args.length==1) {
                directory = new File( args[0] );
            } else {
                JFileChooser fileChooser = new JFileChooser();
                fileChooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
                int result = fileChooser.showOpenDialog( null );
                if ( result == JFileChooser.APPROVE_OPTION ) {
                    directory = fileChooser.getSelectedFile();
                } else {
                    System.err.println("Must select a directory to proceed, exiting.");
            File[] images = directory.listFiles( fileFilter );
            for (File file : images) {
                System.out.println(file);
            System.out.println( "The rest is left an exercise for the reader.  ;-)" );
    class FileFilterType implements FileFilter {
        String[] types;
        FileFilterType(String[] types) {
            this.types = types;
        public boolean accept(File file) {
            for (String type : types) {
                if ( file.getName().toLowerCase().endsWith( type.toLowerCase() ) ) {
                    return true;
            return false;
    }

Maybe you are looking for