| Author |
It doesnot print the content the file
|
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
This code does not print!
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
You need to get into the habit of avoiding stuff like this...
If an error occurs, you will never know it since the application will just catch it and do nothing.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Stephan van Hulst
Bartender
Joined: Sep 20, 2010
Posts: 3050
|
|
First of all, you don't have to check whether a file exists and create it separately. If you're using a FileOutputStream, it will automatically create the file. You can get rid of lines 25 and 26.
The problem is that you're forgetting to flush your output. The data you've written is still in memory.
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
still has problem:
run:
Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = 'i'
at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2605)
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2633)
at java.util.Formatter.parse(Formatter.java:2479)
at java.util.Formatter.format(Formatter.java:2413)
at java.io.PrintStream.format(PrintStream.java:920)
at fiedata.Main.main(Main.java:42)
Java Result: 1
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
The stacktrace describes it all, you just need to learn how to read it.
abalfazl hossein wrote:
run:
Exception in thread "main" java.util. UnknownFormatConversionException: Conversion = 'i'
at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2605)
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2633)
at java.util.Formatter.parse(Formatter.java:2479)
at java.util.Formatter.format(Formatter.java:2413)
at java.io. PrintStream.format(PrintStream.java:920)
at fiedata.Main. main(Main.java:42)
Java Result: 1
On line 42, of your program (Main.java), you are calling the format() method; And this method is encountering an "unknown format" specified as "%i". And if look at the JavaDocs...
http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html
You will see that there is no such format.
Henry
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
still has problem:
run:
java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:375)
at fiedata.Main.main(Main.java:40)
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
abalfazl hossein wrote:
still has problem:
run:
java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:375)
at fiedata.Main.main(Main.java:40)
No offense, but isn't it time to, at least, try to solve the problem yourself? For example, did you even try to look up what an "EOF" means?
Henry
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10816
|
|
|
BeForthrightWhenCrossPostingToOtherSites (other topic)
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
I appreciate henry,But I need the answer.
and also Happy Christmas!! all!
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2782
|
|
Well if you need the answer, it will help a lot to ShowSomeEffort. This is beneficial two ways: it makes people here more willing to help you, and you might learn something.
As a hint: java.io.EOFException is a class in the standard Java library. It's documented like (almost) any standard Java class, in the Java API. In fact the forum software here has helpfully converted the phrase " java.io.EOFException " into a link. If you click on that link, you can get some clue as to what the problem is. If you don't understand it, all right, ask us for more help, and we're here. But please try to type something that shows you've done some work of your own (such as looking up java.io.EOFException to find out what it means).
|
 |
 |
|
|
subject: It doesnot print the content the file
|
|
|