Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Problem finding file in eclipse
icon4.gif  Problem finding file in eclipse [message #1496778] Wed, 03 December 2014 09:01 Go to next message
Charalampos Karandeinos is currently offline Charalampos KarandeinosFriend
Messages: 2
Registered: December 2014
Junior Member
Hallo there. I am a new user of eclipse. I am working on a game i want to
create with eclipse, and i want to store some data and keep scores. So i must handle files. But i have problems finding a file. I am using Scanner to find the file, but every path i insert in new File(" ") doesn't find the file. I also used FileInputsStream and i have the same problem. It is very important to proceed with the game, and i am stuck on something so meaningless.
I want to put text on some buttons, and the text must come from the file.
Here is my code...
package com.example.gh;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;

public class Main extends Activity{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		Button b1=(Button) findViewById(R.id.button1);
        Button b2=(Button) findViewById(R.id.button2);
        b1.setText("test");
        try {	
     			Scanner input = new Scanner(new File("input.txt"));
     			b2.setText("it found it");
     			String s=input.next();		
     		} catch (FileNotFoundException e) {
     			// TODO Auto-generated catch block
     			b2.setText("didn't");
     			e.printStackTrace();
     		}
	}
	}


I get the message "didn't" on the second button all the time.
The organisation of my files for eclipse can be seen in the pic below (i work on the project gh)...
index.php/fa/20121/0/
Any help would be very useful!!! Thanks!!!
  • Attachment: freeze.png
    (Size: 12.14KB, Downloaded 248 times)
Re: Problem finding file in eclipse [message #1497106 is a reply to message #1496778] Wed, 03 December 2014 14:45 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
Your question really has nothing to do with Eclipse, it's a general Java programming question. You'll probably get better response by asking for help on a general programming forum, such as Stack Overflow or Java Ranch.
Previous Topic:Eclipse won't start
Next Topic:Java won't start
Goto Forum:
  


Current Time: Thu Apr 25 15:35:03 GMT 2024

Powered by FUDForum. Page generated in 0.08514 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top