Results 1 to 2 of 2
- 08-05-2007, 05:00 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 35
- Rep Power
- 0
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
Java Code:Prog3test.java:28: openread(java.io.File) in Prog3test cannot be applied to (java.lang.String) String in = openread("input.txt");Thanks.Java 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******* } }
- 08-05-2007, 06:33 AM #2
Similar Threads
-
Operator < cannot be applied to java.lang.Object, Object
By Albert in forum Advanced JavaReplies: 2Last Post: 11-26-2010, 02:12 AM -
Error: cannot resolve symbol' on Person (java.lang.String, java.lang.String)
By baltimore in forum New To JavaReplies: 2Last Post: 09-18-2008, 07:30 AM -
Cast Error Caught (change) Class is really: java.lang.String
By barney in forum Advanced JavaReplies: 1Last Post: 08-02-2007, 04:07 PM -
Error: javax.swing.AbstractButton cannot be applied to...
By barney in forum AWT / SwingReplies: 1Last Post: 08-01-2007, 06:10 AM -
Can't convert java.lang.String to int.
By Albert in forum AWT / SwingReplies: 2Last Post: 07-13-2007, 05:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks