java - I cannot find the error -
i following tutorial here , have been trying working 2 days now. error message when compiling filedata.
filedata.java:13: error: cannot find symbol readfile file = new readfile(file_name); ^ symbol: class readfile location: class filedata filedata.java:13: error: cannot find symbol readfile file = new readfile(file_name); ^ symbol: class readfile location: class filedata
any assistance appreciated.
the code follows:
package textfiles; import java.io.ioexception; public class filedata { public static void main(string[] args) throws ioexception { string file_name = "c:/test.txt"; try { readfile file = new readfile(file_name); string[] arylines = file.openfile(); int i; (i=0; < arylines.length; i++) { system.out.println(arylines[i]); } } catch (ioexception e) { system.out.println( e.getmessage() ); } } } package textfiles; import java.io.ioexception; import java.io.filereader; import java.io.bufferedreader; public class readfile { private string path; public readfile (string file_path) //readfile method { path = file_path; } public string[] openfile() throws ioexception //openfile method { filereader fr = new filereader(path); bufferedreader textreader = new bufferedreader(fr); int numberoflines = readline(); string[] textdata = new string[numberoflines]; int i; (i=0; < numberoflines; i++) { textdata[i] = textreader.readline(); } textreader.close(); return textdata; } int readline() throws ioexception //readlines method { filereader file_to_read = new filereader(path); bufferedreader bf = new bufferedreader(file_to_read); string alines; int numberoflines = 0; while ((alines = bf.readline()) !=null) { numberoflines++; } bf.close(); return numberoflines; } }
the problem java compiler
looking class file
{readfile.class} inside folder textfiles follow compile,
1--> compile readfile using this
javac -d . readfile.java
2--> compile filedata using this
javac -d . filedata.java
note: purpose of
-d
is create appropriate packages during compilation.
Comments
Post a Comment