-
January 16th, 2012, 12:38 PM
#1
Java text file
Hi all I did a program containing text files and now I want to make it on a cd. When I did so an error occured when I ran the program from my cd telling me that access is denied. My program is on currently on my USB. How can I change the path of the files to run on my cd. Here is my main code. Any help would be greatly appreciated. Thx in advance
AVLProcess ap = new AVLProcess();
AVLTree at = ap.ReadInputFile("E:\\Java files txt\\input.txt", "E:\\Java files txt\\output2.txt");
String input = JOptionPane.showInputDialog(null, "Please select a number to search");
Search sr = new Search();
while (input != null) {
try {
Node newNode = sr.search(at.getRoot(), Integer.parseInt(input));
JOptionPane.showMessageDialog(null, "The node you searched for " + input + " is " + newNode.toString());
System.exit(0);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Please enter a valid number to search next time");
System.exit(0);
}
}
-
January 16th, 2012, 12:44 PM
#2
-
January 16th, 2012, 01:31 PM
#3
Re: Java text file
I don't want this type of answer. I want my answer to the question regardless of the tagging. Can you give it?
-
January 16th, 2012, 01:59 PM
#4
Re: Java text file
I don't want this type of answer.
Well we don't want code posted without code tags.
I want my answer to the question regardless of the tagging. Can you give it?
There is a reason we ask for code to be enclosed in code tags and that's because it makes it easier for us to read your code. We give our valuable time and expertise for free and remember you are asking us for help so the least you can do is make it as easy for us as you possibly can.
However, if you can't be bothered to help us by using code tags then that's you choice but don't be surprised if we can't be bothered to help you solve your problem.
-
January 16th, 2012, 02:36 PM
#5
Re: Java text file
Sorry I will not do it again. Cam you pls help me but?
-
January 16th, 2012, 02:49 PM
#6
Re: Java text file
Post the code wrapped in code tags and I will try to help you.
-
January 16th, 2012, 03:24 PM
#7
Re: Java text file
How do I post it pls because I don't know. Forgive me for this time only pls
-
January 16th, 2012, 03:34 PM
#8
Re: Java text file
It's in the signature of all the replies you got from keang (and there were quite a few of them). Put your formatted code inside code tags: [code] and [/code].
-
January 16th, 2012, 04:05 PM
#9
Re: Java text file
[AVLProcess ap = new AVLProcess();
AVLTree at = ap.ReadInputFile("E:\\Java files txt\\input.txt", "E:\\Java files txt\\output2.txt");
String input = JOptionPane.showInputDialog(null, "Please select a number to search");
Search sr = new Search();
while (input != null) {
try {
Node newNode = sr.search(at.getRoot(), Integer.parseInt(input));
JOptionPane.showMessageDialog(null, "The node you searched for " + input + " is " + newNode.toString());
System.exit(0);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Please enter a valid number to search next time");
System.exit(0);
}
}
]
-
January 16th, 2012, 04:08 PM
#10
Re: Java text file
I can't do it sry. Pls help me solving the problem because I'm fed up of trying different solutions
-
January 16th, 2012, 04:12 PM
#11
Re: Java text file
You have to put an opening and closing square bracket with the word 'code' in between them, then your code and finally another opening and closing square bracket with the text '/code' in between them. Not just an opening square bracket, your code and then a closing square bracket.
Look at the line below this one (particularly the bit in blue lettering) .
-
January 16th, 2012, 04:17 PM
#12
Re: Java text file
If you can't put code tags to your code you should probably start considering a career change. It's not rocket science, just type an opening square bracket [, then the word code, then a closing square bracket ], then type/copy+paste your code, then another opening square bracket [, a forward slash /, followed by the word code, and finally a closing square bracket ].
-
January 16th, 2012, 04:37 PM
#13
Re: Java text file
Code:
AVLProcess ap = new AVLProcess();
AVLTree at = ap.ReadInputFile("E:\\Java files txt\\input.txt", "E:\\Java files txt\\output2.txt");
String input = JOptionPane.showInputDialog(null, "Please select a number to search");
Search sr = new Search();
while (input != null) {
try {
Node newNode = sr.search(at.getRoot(), Integer.parseInt(input));
JOptionPane.showMessageDialog(null, "The node you searched for " + input + " is " + newNode.toString());
System.exit(0);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Please enter a valid number to search next time");
System.exit(0);
}
}
-
January 16th, 2012, 04:38 PM
#14
Re: Java text file
I did it now. Can you pls help me in fixing the problem now pls?
-
January 16th, 2012, 04:45 PM
#15
Re: Java text file
You haven't posted the actual error message but I'm guessing it's because you are trying to write the output file to the CD which you can't do. CD are read only devices as far as your application is concerned.
Rather than hard coding the file paths into your program either pass the path in on the command line or use a JFileChooser so you can select the input file when the program runs. You may even want to consider displaying the JFileChooser twice, the first time to select the input file and the second time to select where to save the output file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|