View Single Post
  #1 (permalink)  
Old 08-05-2007, 07:00 AM
carl carl is offline
Member
 
Join Date: Jul 2007
Posts: 35
carl is on a distinguished road
Error: cannot be applied to (java.lang.String)
Hi, I've been starting to go through my programs by doing one part at a time so i don't run into as many errors.
Can someone please look over my open/read method?
I'm getting 1 error when i attempt to compile it I've marked in code where it is
It says this when i try to compile

Code:
Prog3test.java:28: openread(java.io.File) in Prog3test cannot be applied to (java.lang.String) String in = openread("input.txt");
Code:
import java.io.*; import B102.*; class Prog3 { public String openread(File inputfile) { System.out.println("Opening File: " + inputfile.getName()); BufferedReader input = null; String line; try { input = new BufferedReader(new FileReader(inputfile)); while((line = input.readLine())!= null) { break; } } catch(IOException in) { System.out.println("There has been an error."); } finally { // closing file, even on exception try { input.close(); } catch (Exception e) {} } return(line); } public static void main(String[] args) { String in = openread("input.txt"); *******error here******* } }
Thanks.
Reply With Quote
Sponsored Links