Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java read file problem  RSS feed

 
Adam Preston
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have a program which in theory should work perfectly but is failing to produce the out come I expected. I am starting to believe that my firewall(standard windows), anti-virus(Microsoft security essentials) or even my OS(windows vista) is blocking it is blocking this program from working but I am never sure. Here is the code:


please report any errors, thanks! this is the error message that the program produces:
Error: quicksave.txt (The system cannot find the file specified)
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Preston wrote:I am starting to believe that my firewall(standard windows), anti-virus(Microsoft security essentials) or even my OS(windows vista) is blocking it is blocking this program from working


Nope. None of those things are going to hide a file from your program. It's much, much more likely that you just don't know what your current working directory is when you run that program. Perhaps the file exists, but not in your CWD.
 
Adam Preston
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks and I tried that but its still not working. My system has never cooperated with me to read files from other programs.
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adam,

I'm not sure what you mean that you "tried that" in relation to Paul's suggestion.

Try this:



I guarantee that the output from that (i.e., your Java app's working directory) is going to be different from the directory where your file is.


Greg
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Preston wrote:My system has never cooperated with me to read files from other programs.


You don't seem to understand computing very well. There's no "cooperation" taking place there; the computer does what it does, and it's your job to work with that. Blaming the computer will get you nowhere; you can't shame the operating system into doing anything different. It's up to you to make things work.
 
Adam Preston
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Adam Preston wrote:My system has never cooperated with me to read files from other programs.


You don't seem to understand computing very well. There's no "cooperation" taking place there; the computer does what it does, and it's your job to work with that. Blaming the computer will get you nowhere; you can't shame the operating system into doing anything different. It's up to you to make things work.


Okay I agree with you. But now may I point out to you that actually I am looking for help on how to overcome this problem not criticisms on my level of understanding in computing. Btw I'm 14 therefore I wouldn't be surprised if my understanding of computing is low however as I am learning I/O at the age of 14 in the UK where they have not inherited America's education curriculum of computer programming in schools, I do not believe there is much to complain about.
 
Adam Preston
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Charles wrote:Hi Adam,

I'm not sure what you mean that you "tried that" in relation to Paul's suggestion.

Try this:



I guarantee that the output from that (i.e., your Java app's working directory) is going to be different from the directory where your file is.


Greg


Thanks sorry I thought Paul's suggestion meant to put the file I was trying to use in the directory of my working folder (the folder where all my projects are stored in eclipse) Btw you gave me a line of code to work with but where in my program should I put it and should I make any alterations to the line of code. But I will play about with the code anyway try and make it work till you reply.
 
Adam Preston
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you it worked! I believed i should put it where all my projects were stored in the 'bin' directory of my working space but you were right.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Preston wrote:But now may I point out to you that actually I am looking for help on how to overcome this problem not criticisms on my level of understanding in computing.


That wasn't a criticism. I'm sure you understand how computers behave; I was pointing out that blaming the computer was not going to be a practical method of overcoming that problem. If you're going to be a programmer then your attitude needs to be "I must have done something wrong, what can I change to fix the problem?" Because 99.99% of the time it will be you doing something wrong. That's what I find when I do programming, anyway.
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good for you Adam! Programming can be frustrating, but also satisfying. Keep at it!

Paul, I think you're just not trying hard enough. I've found that with the right mixture of sarcasm and rage, I can get my Java compiler to compile Ruby code. You just have to know what scares it.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Charles wrote:Paul, I think you're just not trying hard enough. I've found that with the right mixture of sarcasm and rage, I can get my Java compiler to compile Ruby code. You just have to know what scares it.


Well, I'm surprised. I'm pretty good at sarcasm, except it isn't nice so I try not to use it around here. So maybe I'm going to have to work on my rage a bit?
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitesh Pandey,
Your post was moved to a new topic.
 
Ron Savoy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have the exact same problem, I tried doing as suggested here, and the directory it outputs IS the directory where my file is (yes, I've double and triple checked that this is the directory, and that the file is named correctly).

Any thoughts??

Ron
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!