Results 21 to 35 of 35
Thread: Files. What is wrong with this??
- 11-17-2011, 01:35 AM #21
- 11-17-2011, 02:03 AM #22
Member
- Join Date
- Nov 2011
- Posts
- 24
- Rep Power
- 0
Re: Files. What is wrong with this??
Ha...no. I tried that. I entered it before the import statements. It said I was missing an enum or class or something. So I tried it after the class statement. didn't work there either. Sorry man.
- 11-17-2011, 02:09 AM #23
Re: Files. What is wrong with this??
You need to put Junky's code in the main method.
- 11-17-2011, 02:12 AM #24
Re: Files. What is wrong with this??
Wow! I guess I should have been explicit.
- 11-17-2011, 02:22 AM #25
Re: Files. What is wrong with this??
It doesn't help. Post #13 implies to put the code after line 9.
- 11-17-2011, 02:45 AM #26
Member
- Join Date
- Nov 2011
- Posts
- 24
- Rep Power
- 0
Re: Files. What is wrong with this??
I'm sorry guys, like I said, total beginner here. Here's what I did:
and it returns nothing. Just the same error from before. Maybe I'm beyond help...i don't know.Java Code:public static void main(String[] args)throws IOException { String firstfile; String secondfile; Scanner keyboard= new Scanner(System.in); System.out.println(System.getProperty("user.dir")); System.out.println("Enter the name of file 1"); firstfile= keyboard.nextLine(); System.out.println("Enter the name of file 2"); secondfile= keyboard.nextLine(); UpperCaseFile object= new UpperCaseFile(firstfile, secondfile); System.exit(0); } }
- 11-17-2011, 02:48 AM #27
Member
- Join Date
- Nov 2011
- Posts
- 24
- Rep Power
- 0
Re: Files. What is wrong with this??
Oops. Ok it returned this: C:\Users\olle\Documents\JCreator LE\MyProjects\UpperCaseFile\classes
So. I should save my notepad file here then right?
- 11-17-2011, 02:50 AM #28
Re: Files. What is wrong with this??
What happened when you tried?
- 11-17-2011, 02:51 AM #29
Re: Files. What is wrong with this??
Try it. It won't break anything and you'd be able to tell us what happened instead of waiting for our telling you what we think.
Did you try printing the absolutePath for the File class? What does it print?
- 11-17-2011, 02:54 AM #30
Member
- Join Date
- Nov 2011
- Posts
- 24
- Rep Power
- 0
Re: Files. What is wrong with this??
Ok. I tried it. And I get this:
Enter the name of file 1
abc.txt
Enter the name of file 2
ABC.txt
Process completed.
So when I go back in to abc.txt it should be Uppercase right? But it's not, nothing changed.
- 11-17-2011, 02:58 AM #31
Re: Files. What is wrong with this??
Windows file names are not case sensitive.
ABC.txt is the same file as abc.txt
Use different filenames for input and output.
In general for testing you should always use different filenames.
- 11-17-2011, 03:00 AM #32
Re: Files. What is wrong with this??
Unless it created ABC.txt in a different directory. If that is true then down the rabbit hole we go again.
- 11-17-2011, 03:01 AM #33
Member
- Join Date
- Nov 2011
- Posts
- 24
- Rep Power
- 0
Re: Files. What is wrong with this??
Holy crap! I finally got it. Wow..that was way harder than it should've been. Thanks a ton you guys! Also your patience is greatly appreciated. :)
- 11-17-2011, 03:12 AM #34
Re: Files. What is wrong with this??
Wooohoooo!
- 11-17-2011, 03:51 AM #35
Member
- Join Date
- Nov 2011
- Posts
- 3
- Rep Power
- 0
Re: Files. What is wrong with this??
You must give the full file path in order to provide right job to the code. Program must know what to do on what.
If I am not too primitive in java programming, this style is correct as I did in my code
Java Code:
public static void main(String[] args) throws IOException {
...
File inputFile = new File("D:\\images\\myImage.png");
...
}
Similar Threads
-
Wrong output (well.. the one who's wrong is probably me ;) )
By shacht1 in forum New To JavaReplies: 4Last Post: 06-11-2013, 01:37 AM -
Java webstart having problem with multiple jar files and resource files
By rjalori in forum AWT / SwingReplies: 2Last Post: 06-11-2011, 01:54 PM -
Creating Jar Files with functioning input files
By appleLove in forum NetBeansReplies: 1Last Post: 04-10-2011, 10:37 PM -
Convert avi, mpeg, wmv media files to .flv files in java code
By vinay1497 in forum New To JavaReplies: 8Last Post: 07-30-2010, 05:47 PM -
Behaving text files like binary files
By Farzaneh in forum New To JavaReplies: 2Last Post: 08-27-2008, 03:20 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks