• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

It doesnot print the content the file

 
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This code does not print!
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Saloon Keeper
Posts: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BeForthrightWhenCrossPostingToOtherSites (other topic)
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I appreciate henry,But I need the answer.

and also Happy Christmas!! all!
 
Master Rancher
Posts: 4830
74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic