15,906,316 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 14767000 (Top 7 by date)
Member 14767000
17-Dec-20 14:37pm
View
Thank you so much for the help, I've figured out where to put the file and now everything works!
Member 14767000
17-Dec-20 10:36am
View
I put "throws FileNotFoundException" and now it works, thank you! However, both the "input.txt" and "Main.java" are in the same folder so why can't the file be found if I instead put:< File file = new File("input.txt"); >. When I use file.exists() to check if it exists, it returns false in this case. Why can't File find the file?
public static void main(String[] args) throws FileNotFoundException
{
// File file = new File("C:/Users/josep/OneDrive/Documents/java/input.txt/");
File file = new File("input.txt"); //why won't this work?
if( file.exists() )
{
System.out.println("File exists");
}
else
{
System.out.println("Doesn't exist"); //This prints out.
}
//System.out.println(file.getAbsolutePath());
Scanner input = new Scanner(file);
String str = input.nextLine();
System.out.println("Str: " + str);
input.close();
}
Member 14767000
17-Dec-20 10:22am
View
The slash was actually not the issue. I had just put the slash to see if it'd work but it still did not. The issue was that I did not put a try catch block or "throws FileNotFoundException". Thank you for your input!
Member 14767000
17-Dec-20 10:22am
View
Deleted
The slash was actually not the issue. I had just put the slash to see if it'd work but it still did not. The issue was that I did not put a try catch block or "throws FileNotFoundException". Thank you for your input!
Member 14767000
24-Apr-20 17:10pm
View
I tried, but I got a correct solution already. It turns out that doing if(isdigit(...) == true) isn't a good idea and that I am supposed actually just do if((isdigit(...)). Thank you for your responding!
Member 14767000
24-Apr-20 17:07pm
View
Thank you for you're input!
Member 14767000
24-Apr-20 14:11pm
View
Ok so... doing what you said and changing:
if (isdigit(expression.at(i)) == true)
to:
CHAR c = expression.at(i);
if( isdigit(c) )
seems to have fixed it. It now gives me the right output. Thank you so much, but could you please explain to me why doing the former is not ok, cause I've done that a lot in the past before I started using visual. Thank you.
Show More