Source Code : Read data from text file
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Read data from text file
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class InputFileDeclared {
private FileInputStream in;
public InputFileDeclared(String filename) throws FileNotFoundException {
in = new FileInputStream(filename);
}
public String getWord() throws IOException {
int c;
StringBuffer buf = new StringBuffer();
do {
c = in.read();
if (Character.isSpace((char) c))
return buf.toString();
else
buf.append((char) c);
} while (c != -1);
return buf.toString();
}
public static void main(String[] args) throws java.io.IOException {
InputFileDeclared file = new InputFileDeclared("testing.txt");
System.out.println(file.getWord());
System.out.println(file.getWord());
System.out.println(file.getWord());
}
}
Thank with us