score:1
the path of the file is absolute to your project. in your case homework_one
so if you want to access alice2.txt try "./alice2.txt"
or for alice.txt ./src/com/abenson/hw0/three/alice.txt
public static void main(string[] args) throws filenotfoundexception {
file tester = new file("./alice2.txt"); // or new file("./src/com/abenson/hw0/three/alice.txt");
system.out.println(tester.getabsolutepath());
scanner in = new scanner(tester);
system.out.println(in.hasnext());
in.close();
}
score:0
score:0
you took the right approach which is to print the absolute path. imo the only reasonable explanation is that you did not put enough attention to checking it. can you try to re-run it and compare the paths: the one printed and the one you see right clicking and checking file properties?
typically the output of the program will be on most setups:
<your_workspace_path>\<your_project_path>\alice2.txt
whereas you want
<your_workspace_path>\<your_project_path>\src\fr\test\alice2.txt
Source: stackoverflow.com
Related Query
- Java won't open the correct file, constantly returns the File Not Found Exception even when using the absolute path
- class not found exception in eclipse even though the user library containg jar file is in java build path
- Class not found exception in java though I have the jar file
- showing file not found exception even i configure the spring configuration file at servlet class level in web.xml
- Fixing file not found exception in Java
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- @throws in Scala does not allow calling Java to catch correct exception type
- the superclass "javax.servlet.httpServlet" was not found on the Java Build Path
- "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- Java Eclipse--.txt File Not Found When Exported To .jar
- Source not found for a file that I have open
- Eclipse --launcher.openFile does not open the file
- Could not open the editor: An unexpected exception was thrown in Eclipse Android
- Warning in jsp : The tag handler class for "s:form" (org.apache.struts2.views.jsp.ui.FormTag) was not found on the Java Build Path
- SRVE9967W: The manifest class path xercesImpl.jar can not be found in jar file
- Class not found exception after adding a new image to the resource folder
- Eclipse WindowsBuilder - Could not open the editor: An unexpected exception was thrown in Ubuntu
- Java Calendar.getTime() returns null exception message in Android but not Java project
- How to open folder of a file not in the project explorer in Eclipse IDE?
- Java (Android) - class not found exception
- java FileNotFoundException wont locate a file in the same project
- Eclipse error in JSP file: The superclass "javax.servlet.http.HttpServlet" was not found on the java build path
- Debugging java source file with multiple classes in eclipse: Source not found
- Eclipse plugin - file not found exception
- IWAE0006E Archive is not a valid WAR File because the deployment descriptor can not be found (case sensitive): WEB-INF/web.xml
- How do I bind 2 java files so they both open when I run the jar file
- Eclipse Class File Editor Source not Found when adding library to java project
- sonarqube analysis failed in eclipse throws error on local analysis due to the exception language "cpp" is not found
- I am not able to open open-in-jd-gui.sh in my ubuntu terminal.how to use the open-in-jd-gui.sh tar file
- BlackBerry - bbwp.exe returns file not found error
More Query from same tag
- The type org.springframework.beans.factory.support.BeanNameGenerator cannot be resolved Without Maven
- Access is Denied, Issue in embedded Derby
- can i use GCM (google cloud messaging) as sms gateway
- How to set relative path in ant script with spacing?
- How to make Eclipse automatically show selected file in explorer?
- GUI update works in IDE but not always from jar file
- eclipse error represented by a small question mark attatched to file icons
- How to use the compiled HelloIOIO sample?
- Eclipse EE + Webstorm development: enable automatic update of static web files on server
- Not getting the Python Run option in PyDev perspective
- How to get path of file using System Specific separator from Eclipse
- My Android Game is Crashing (Unfortunately stopped)
- launch file(.exe) is missing after building rcp application on Jenkins
- How Test eclipse product using TestComplete..?
- How to update the maven version without pom backup files
- Call Python google cloud endpoint api from android
- linphone android login error java.lang.UnsatisfiedLinkError: Native method not found
- Need to make a ant build file for eclipse project
- Stop eclipse renaming inside strings
- An Import-Package could not be resolved Error in Deploying Flex UI project
- setting a button two tasks but only doing one at a time depending on toggle state
- Error in OK button selection listener in a SWT/JFace Dialog
- How to work with different Activity , and send String("text") to an EditText?
- Eclipse Plugins - Null Pointers
- parsing org.json.jsonexception value <br type java.lang.String cannot be converted to JSONOobject
- how to import java.util.Scanner
- Blackberry simulator not creating COD file
- What is the Eclipse equivalent of the NetBeans "Run As Main"?
- how do i create a debuggable axis2 project in eclipse using maven?
- Could not find class 'android.webkit.WebResourceResponse' when running HelloCordova on Android 2.2