1

This may sound easy but I when debugging through this code it just stops debugging, can't work out if its throwing an exception or not. What am I doing wrong?

Writer output = null;
File file = new File("write.txt");
output = new BufferedWriter(new FileWriter(file));
for (int i = 0; i < audioDataDoubles.length; i++) {
    output.write(audioDataDoubles[i] + "\n");
}

output.close();
8
  • Stuck on the first line of code (Writer output = null)? Or stuck on the first line of the for loop? Commented Oct 5, 2011 at 17:11
  • It would be REALLY odd for it to hang on Writer output = null; maybe on the File.... = new File...? Commented Oct 5, 2011 at 17:14
  • Updated the question, I think its throwing an exception but cant see why Commented Oct 5, 2011 at 17:15
  • @Ben, please post the exception Commented Oct 5, 2011 at 17:16
  • 1
    As you don't give a full path, it defaults to the current working directory. The message you quote pretty clearly says that you do not have authority to write in that directory. That would be your problem. Commented Oct 5, 2011 at 17:35

1 Answer 1

2

It might be the case that you are creating a file at the location where you dont have the write access. Make sure if you have that.

Sign up to request clarification or add additional context in comments.

4 Comments

I changed the string and now I get this message: /C:/Users/Ben/Desktop/out.txt (No such file or directory) There is a text file called out.txt on my desktop, any ideas?
Is it giving you out.txt, or write.txt ??
sorry, out.txt. I had an empty text file on my desktop that i used as a test.
I forgot to mention I was using Android, debugging on my phone. I imagne its looking on my phone for storage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.