Results 1 to 4 of 4
- 07-26-2010, 06:27 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
reading a file and writing to a file....help!!!!
here is my code:
import java.util.*;
import java.io.*;
public class ReadFile {
public static void manin(String[] args) throws FileNotFoundException {
Scanner inFile = new Scanner(new FileReader("C:\\Users\\Usman\\Desktop\\employeeDat a.txt"));
PrintWriter outFile = new PrintWriter("C:\\Users\\Usman\\Desktop\\wages.txt" );
String Firstname, Lastname;
double hours,payrate,wages;
Firstname = inFile.next();
Lastname = inFile.next();
hours = inFile.nextDouble();
payrate = inFile.nextDouble();
wages = hours*payrate;
outFile.println("$"+wages);
inFile.close();
outFile.close();
}
}
Plz tell me what am i doing wrong in this. i want my file to be saved on the desktop and read from the desktop. the file that is being read is on my desktop but it is not being read, plz tell me y?
also wat is my default directory, i cant find it?
- 07-26-2010, 06:44 PM #2
I see two problems that catch my eye immediately:
1. Your code is not in [code] tags.
2. Your main method is misspelled:
Have not yet looked further; correct #2 and test your code to see if there's still an issue.Java Code:public static void manin(String[] args) throws FileNotFoundException {
- 07-26-2010, 06:48 PM #3
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
zack, thnx alot. i actually feel embarrassed for such a dumb mistake. im so used to copying and pasting from a template, and the first time i actually wrote the main method statement, i mispelled.
thnx again
- 07-26-2010, 06:53 PM #4
Similar Threads
-
File reading / writing
By MattBSibley in forum New To JavaReplies: 5Last Post: 04-19-2010, 05:20 AM -
Reading and Writing the contents of a file to another file
By priyankatxs in forum New To JavaReplies: 9Last Post: 10-20-2009, 10:52 AM -
[SOLVED] how to reading binary file and writing txt file
By tOpach in forum New To JavaReplies: 3Last Post: 05-09-2009, 11:31 PM -
Reading and writing to a file
By jigglywiggly in forum New To JavaReplies: 13Last Post: 03-09-2009, 10:44 AM -
Help with File reading and writing
By baltimore in forum New To JavaReplies: 1Last Post: 07-31-2007, 06:47 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks