java - ReadFile cannot be resolved to a type -


i consider rookie , have searched hours on internet solve problem still no luck.

i want understand java , if explain detail highly grateful.

the problem in line

readfile file = readfile(file_name);  error message : "readfile cannot resolved  type." 

here code: filedata.java

package textfiles; import java.io.ioexception;  public class filedata {      public static void main (string[] args) throws ioexception {          string file_name = "d:/java/readfile/test.txt";          try {              readfile file = 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() );         }      }        } 

and other code: readfile.java

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) {          path = file_path;      }     int readlines () throws ioexception{          filereader file_to_read = new filereader(path);         bufferedreader bf = new bufferedreader(file_to_read);          string aline;         int numberoflines = 0;          while (( aline = bf.readline() )  != null) {              numberoflines++;          }          bf.close();          return numberoflines;     }     public  string[] openfile () throws ioexception {          filereader fr = new filereader (path);         bufferedreader textreader = new bufferedreader (fr);           int numberoflines = readlines();         string[] textdata = new string[numberoflines];          int i;          (i=0; < numberoflines; i++) {              textdata[i] =textreader.readline();         }           textreader.close();         return textdata;     } } 

try this:

readfile file = new readfile(file_name); 

in order initialize object it's class name should use new key word this:

classname objname = new classname(arguments); 

from rest of code seems know notion, nevertheless refer (or possible future visitors) this page.


Comments

Popular posts from this blog

My HTML document is not linking to my CSS stylesheet properly -

php array slice every 2th rule -

node.js - Sending sockets to client side, Error: Converting circular structure to JSON -