Hi,
I'm trying to read a file in
java but I can't due to an error. The code is:
import java.io.*;
class formato
{
public static void main(
String args[])
{
try
{
FileReader fis = new FileReader("proveedores.txt");
}
catch (FileNotFoundException ex)
{
System.out.println("File not found");
return;
}
DataInputStream dis;
try
{
dis = new DataInputStream(dis);
}
catch (FileNotFoundException ex)
{
System.out.println("File not found");
}
}
}
When I compile this code I display two errors:
formato.java:22: variable dis might not have been initialized
dis = new DataInputStream(dis);
^
formato.java:24: exception java.io.FileNotFoundException is never thrown in body
of corresponding try statement
catch (FileNotFoundException ex)
^
2 errors
How I can solve them?
Thanks.