Hi all. I'm getting a error when I compile the code bellow. javac spits out: exception java.io.IOException is never thrown in body of corresponding try statement: catch(IOException e4) {
I've looked and looked but I can't find where I'm going wrong. It really ticks me off. Anyways, thanks for your time and here's the code:
import java.io.*;
import java.net.*;
public class FRClient {
public static void main(String args[]) {
Socket server = null;
PrintWriter pw = null;
String filename = args[0];
try {
server = new Socket("192.168.2.5",1234);
}
catch(UnknownHostException e) {
System.err.println("Unknown host: " + e);
}
catch(IOException e) {
System.err.println("Error creating socket: " + e);
}
try {
pw = new PrintWriter(new OutputStreamWriter(server.getOutputStream()));
}
catch(IOException e2) {
System.err.println("Error creating writer: " + e2);
}
try {
File source = new File(filename);
FileReader fr = new FileReader(source);
BufferedReader fileReader = new BufferedReader(fr);
String line = null;
while((line = fileReader.readLine()) != null) {
pw.println(line);
}
fileReader.close();
}
catch(FileNotFoundException e) {
System.err.println("File not found.");
}
catch(IOException e3) {
System.err.println("Error reading or sending file: " + e3);
}
finally {
try {
pw.flush();
pw.close();
}
catch(IOException e4) { \\here is where I get the error
System.err.println(e4);
}
}
}
}