Bonjour a tous, je vous expose mon probleme.
Je voudrai tout simplement remplir ma liste deroulante avec les donnees inserees dans un fichier.txt
Mais lorsque je compile mon programme un message d'erreur apparait:
unreported exception java.io.IOException; must be caught or declared to be thrown.
Voila mon code (une partie) :
//La liste deroulante
public void init()
{
calcConstraints.gridx = 0;
calcConstraints.gridy = 20;
calcConstraints.gridwidth = 4;
calcConstraints.gridheight = 1;
calcConstraints.weightx = 5;
calcConstraints.weighty = 1;
calcConstraints.fill = GridBagConstraints.HORIZONTAL;
calcConstraints.anchor = GridBagConstraints.CENTER;
calcConstraints.insets = calcInsets;
calcConstraints.ipadx = 0;
calcConstraints.ipady = 0;
cbCountry.addItem("Convert");
listCountry(); // Mon probleme vient de la
cbCountry.setActionCommand("CONVERT");
cbCountry.addActionListener(this);
add(cbCountry, calcConstraints);
}
//La fonction qui renplit la liste deroulante
private void listCountry() throws IOException
{
BufferedReader lecteurAvecBuffer=null;
String ligne;
try
{
lecteurAvecBuffer = new BufferedReader
(new FileReader("I:\\SitesWeb\\Djo Corporation\\data.txt"));
}
catch(FileNotFoundException exc)
{
System.out.println("Erreur d'ouverture");
}
while ((ligne = lecteurAvecBuffer.readLine())!=null)
//System.out.println(ligne);
cbCountry.addItem(ligne);
lecteurAvecBuffer.close();
}
Je vous remercie d'avance de votre votre attention
---------
le pastis est à consommer avec modération
Afficher la suite