File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply locked New topic


unyime inok

Joined: Oct 13, 2004
Posts: 29 (No such file or director
at Method)
at IntFile.<init>(
at TestIntFile.main(

public class IntFile {

File inputFile = new File("");
File outputFile;
FileInputStream fsr;
BufferedReader bufFile;
InputStreamReader isrFile;
String inString;
boolean eofFlag = false;

public IntFile(String inString) {
BufferedReader keyboard = new BufferedReader(new InputStreamReader(;

inString = new String();

System.out.println("Enter file name\t?");
File inputFile = new File(inString);

try {
inString = keyboard.readLine();

} catch (IOException ioe) {

System.err.println("Couldnot read file");

FileInputStream fsr =null;
fsr = new FileInputStream(inputFile);
}catch(IOException ioe){
//System.err.println("file not found");

InputStreamReader isr = new InputStreamReader(fsr);
BufferedReader bufFile = new BufferedReader(isr);

public int readInteger() {
int inputInteger = 0;
inString = readinString();
if (inString ==null) {
eofFlag = true;
return 0;
inString = inString.trim();
if (inString.equals("")) {
eofFlag = true;
return 0;
inputInteger = Integer.parseInt(inString);
return inputInteger;

public String readinString() {
String inString = new String();

while(!eofFlag) {
try {
inString = bufFile.readLine();
} catch (EOFException eof) {
eofFlag = true;
} catch (IOException ioe) {
System.err.println("Could not read file");
//if (!eofFlag)

return inString;

public boolean getEOF() {
return eofFlag;



public class TestIntFile {
public static void main(String [] args)
throws IOException {

Array me = new Array();


final int arraySize = 10;
IntFile inf = new IntFile("");
int[] array = new int[arraySize];
int i, size;

for(i=0; i<arraySize; i++) {
if (inf.getEOF())
array[i] = inf.readInteger();
if (i <arraySize)
size = i-1;
size = arraySize;

for(i=0; i<size; i++)
System.out.println("x[" + i + "] = " + array[i]);
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
Please use the code UBB tags to format your code. Long code segments that are not formatted are very difficult to read.

The error you're seeing usually means the file you're trying to open does not exist in the directory in which you're trying to access it. If you re-post the code with formatting, I'll take a look at it.


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
I agree. Here's the link:
subject: Help!
It's not a secret anymore!