Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within I/O and Streams
Search Coderanch
Advance search
Google search
Register / Login
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
I/O and Streams
FileNotFoundException,(help please)
unyime inok
Greenhorn
Posts: 29
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
java.io.FileNotFoundException: (No such file or director at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream at IntFile.<init>(IntFile.java:33) at TestIntFile.main(TestIntFile.java:12) import java.io.*; public class IntFile { File inputFile = new File("Array.java"); File outputFile; FileInputStream fsr; BufferedReader bufFile; InputStreamReader isrFile; String inString; boolean eofFlag = false; public IntFile(String inString) { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); 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"); System.exit(1); } try{ FileInputStream fsr =null; fsr = new FileInputStream(inputFile); }catch(IOException ioe){ ioe.printStackTrace(); //System.err.println("file not found"); System.exit(2); } 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"); System.exit(3); } //if (!eofFlag) } return inString; } public boolean getEOF() { return eofFlag; } } //MAIN import java.io.*; public class TestIntFile { public static void main(String [] args) throws IOException { Array me = new Array(); me.readInt(); me.writeInt(); final int arraySize = 10; IntFile inf = new IntFile("Array.java"); int[] array = new int[arraySize]; int i, size; for(i=0; i<arraySize; i++) { if (inf.getEOF()) break; array[i] = inf.readInteger(); } if (i <arraySize) size = i-1; else size = arraySize; for(i=0; i<size; i++) System.out.println("x[" + i + "] = " + array[i]); } }
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
reading integer from a file
Help! java.io.FileNotFoundException
reading an integer from a file
Array IndexOutOfBounds Exception
please help figure out why the standard deviaion is not giving the correct output
More...