load image with ImageIcon component

Hello,

I want to load an image whose name or path contains special character such as accents (a french name). So that generates an exception. For exemple for an image named caf.jpeg I obtain this message :

java.io.FileNotFoundException: /media/disk/images/caf.jpeg (No such file or directory)

Can you please help me.

Thanks in advance.

[373 byte] By [WebServicea] at [2007-11-27 11:24:33]
# 1

hi,

get this sample example and develop

import javax.swing.*;

import javax.swing.event.*;

import javax.swing.ImageIcon;

import java.io.*;

import java.awt.*;

import java.awt.event.*;

public class ji extends JApplet

{

public Icon pulicon;

public JButton b1;

public void init()

{

getContentPane().setLayout(null);

this.setSize(744, 536);

pulicon = new ImageIcon(getImage(getCodeBase(),"bullet.gif"));

b1 = new JButton(pulicon);

getContentPane().add(b1);

b1.setBounds(50,50,42,42);

}

}

//<applet code="ji.class" height="200" width="200"></applet>

that gif picture from current dir, where your class file stores.. if u want specify the path there

drvijayy2k2a at 2007-7-29 15:58:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

This has nothing to do with JSF.

Anyway, you've clearly a charset encoding problem. Set the charset encoding right according to your locale. UTF-8 might be sufficient.

BalusCa at 2007-7-29 15:58:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

How can I do this please.

Thanks for your reply.

WebServicea at 2007-7-29 15:58:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...