Results 1 to 3 of 3
Thread: Need help with PrintWriter!
- 10-02-2011, 09:10 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 2
- Rep Power
- 0
Need help with PrintWriter!
Hello, my first post. It doesn't write anything to the file.
Sry for the variables, it's in Swedish.gif)
Now when it's running I get this problem.Java Code:PrintWriter skrivfil = new PrintWriter(new BufferedWriter(new FileWriter("LagerV.txt"))); enrad = readfil.nextLine(); Artikel a2 = new Artikel(enrad); skrivfil.println(a2.geteanKod() + a2.getvaruNamn() + a2.getlagerVr());
I've tried if it prints out anything in the file only by not giving the variables no values, I get null.Java Code:Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1516) at lagerV.main(lagerV.java:27)
Java Code:PrintWriter skrivfil = new PrintWriter(new BufferedWriter(new FileWriter("LagerV.txt"))); skrivfil.println(a2.geteanKod() + a2.getvaruNamn() + a2.getlagerVr())
-
Re: Need help with PrintWriter!
And welcome to java-forums.org!
Now when it's running I get this problem.Java Code:PrintWriter skrivfil = new PrintWriter(new BufferedWriter(new FileWriter("LagerV.txt"))); enrad = readfil.nextLine(); Artikel a2 = new Artikel(enrad); skrivfil.println(a2.geteanKod() + a2.getvaruNamn() + a2.getlagerVr());
I've tried if it prints out anything in the file only by not giving the variables no values, I get null.Java Code:Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1516) at lagerV.main(lagerV.java:27)
Java Code:PrintWriter skrivfil = new PrintWriter(new BufferedWriter(new FileWriter("LagerV.txt"))); skrivfil.println(a2.geteanKod() + a2.getvaruNamn() + a2.getlagerVr())
This:
Tells you that the problem is not with the PrintWriter but with the Scanner object, readfil. It is trying to read in a line, but no line exists.Java Code:Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1516) at lagerV.main(lagerV.java:27)
- 10-09-2011, 06:51 PM #3
Member
- Join Date
- Oct 2011
- Posts
- 2
- Rep Power
- 0
Re: Need help with PrintWriter!
Thx! I got it working! But it's strange, I only manage with success run it on Mac! It doesn't work on Windows? (Windows trash! ;D) I can compile it and run it, but I get this error...
What is wrong? My constructor? Just tell me if you want to see the code.
Java Code:Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextDouble(Unknown Source) at Artikel.<init>(Artikel.java:19) at LagerV.main(LagerV.java:22)
Similar Threads
-
printwriter
By sope in forum New To JavaReplies: 2Last Post: 05-09-2011, 07:57 PM -
java PrintWriter
By miko5054 in forum New To JavaReplies: 3Last Post: 05-08-2011, 01:25 PM -
printWriter problem
By Lund01 in forum Advanced JavaReplies: 6Last Post: 10-14-2010, 01:28 PM -
Help with printwriter class
By eel in forum New To JavaReplies: 9Last Post: 09-19-2010, 02:04 PM -
Help with printwriter.
By Addez in forum New To JavaReplies: 2Last Post: 10-30-2009, 01:58 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks