I’m learning how to use Java.io to manipulate and read files but I need the programs to be finished and ready to open with a .jar
As is, the code works fine, in the IDE it runs, but when I compress it and open the .jar the catch(FileNotFoundException e) error appears
package com.example;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@SuppressWarnings("unused")
public class EjemploFichero01 {
public static void main(String[] args) {
try{
BufferedReader bf = new BufferedReader(new FileReader("malaga1.csv"));
String linea = "";
while ((linea = bf.readLine()) != null) {
System.out.println(linea);
}
bf.close();
}catch (FileNotFoundException e){
System.out.println("No se encuentra el fichero malaga.txt");
}catch (IOException e){
System.out.println("No se puede leer el fichero malaga.txt");
}
}
}
Tried to run the .jar file expecting the content of the file “malaga1.csv” to appear but i get the catch (FileNotFoundException e) error
I also run the -jar with
java -jar –enable-preview demo.jar
Maziu27 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.