5 Replies - 799 Views - Last Post: 25 January 2009 - 02:25 PM Rate Topic: -----

#1 litterbug_kid  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 29-January 08

Trouble getting input from a file

Post icon  Posted 25 January 2009 - 11:10 AM

I'm trying to run this example code given to me in a Java pack by my lecturer, and am having trouble getting input from a file

import java.io.*;

class Example1_2 {

	private void displayFileContent(String filename) {
		FileInput fileIn = new FileInput(filename);
		
		while (fileIn.hasNextLine()) {
			String s = fileIn.nextLine();
			System.out.println(s);
		}
		
		fileIn.close(); 
	}
	
	private String getFileName() {
		Input in = new Input();
		System.out.print("Enter filename: ");
		String filename = in.nextLine();
		return filename;
	}
	
	public void showFile() {
		String filename = getFileName();
		displayFileContent(filename);
	}
	
	public static void main(String[] args) {
		new Example1_2().showFile();
	}
}



error message:
cannot find symbol - class FileInput

Any help would be much appreciated

Is This A Good Question/Topic? 0
  • +

Replies To: Trouble getting input from a file

#2 markhazlett9  Icon User is offline

  • Coding is a lifestyle
  • member icon

Reputation: 60
  • View blog
  • Posts: 1,666
  • Joined: 12-July 08

Re: Trouble getting input from a file

Posted 25 January 2009 - 11:19 AM

I'm pretty sure that that means the file could not be found. Make sure the file is in the correct directory on your computer.
Was This Post Helpful? 0
  • +
  • -

#3 litterbug_kid  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 29-January 08

Re: Trouble getting input from a file

Posted 25 January 2009 - 11:20 AM

View Postmarkhazlett9, on 25 Jan, 2009 - 06:19 PM, said:

I'm pretty sure that that means the file could not be found. Make sure the file is in the correct directory on your computer.


The file FileInput?
Was This Post Helpful? 0
  • +
  • -

#4 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2650
  • View blog
  • Posts: 15,673
  • Joined: 24-September 08

Re: Trouble getting input from a file

Posted 25 January 2009 - 11:26 AM

Are they static? Is it all within scope? Sometimes the file variables get outta scope. It looks like you can only acess the FileInput from main method. Try putting it in the main class, not in the method.

Are they static? Is it all within scope? Sometimes the file variables get outta scope. It looks like you can only acess the FileInput from main method. Try putting it in the main class, not in the method.
Was This Post Helpful? 0
  • +
  • -

#5 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Re: Trouble getting input from a file

Posted 25 January 2009 - 11:26 AM

From what i can deduce right now, is that there is a class named File Input that has to placed in the class path of your java program...
Here is sample code for a core java input: http://www.java.happ...ava/code29.html
i hope this helps, good luck...

This post has been edited by ayman_mastermind: 25 January 2009 - 11:31 AM

Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8328
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Trouble getting input from a file

Posted 25 January 2009 - 02:25 PM

View Postlitterbug_kid, on 25 Jan, 2009 - 10:20 AM, said:

View Postmarkhazlett9, on 25 Jan, 2009 - 06:19 PM, said:

I'm pretty sure that that means the file could not be found. Make sure the file is in the correct directory on your computer.


The file FileInput?

The file FileInput.class
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1