aspose file tools*
The moose likes I/O and Streams and the fly likes file created,but nothing inside Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "file created,but nothing inside" Watch "file created,but nothing inside" New topic
Author

file created,but nothing inside

jyothi abraham
Ranch Hand

Joined: Aug 14, 2001
Posts: 46

Here in the file created(hello.bmp) doesnt contain
anything that is in jyo.bmp,infact an empty file.
Why so?Any body could write a program so that
it contains what is inside jyo.bmp
[ May 10, 2002: Message edited by: Dirk Schreckmann ]
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Be sure to close() and/or flush() the OutputStream
jyothi abraham
Ranch Hand

Joined: Aug 14, 2001
Posts: 46
I used out.flush() and out.close(),but no desired
result.
(please comment out the line in for loop;
size = -1)
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Your program "kinda-sorta" works for me (after making the necessary correction in the FileInputStream construction) - even without the calls to flush and/or close.
The file it creates is not empty - it is the same size as the original file. I can edit and view both the original bitmap file and the copied file using Microsoft Paint. I cannot view the copied file with the Windows XP standard image viewer - so the copied file must not be exactly the same. The result is similar whether explicitly invoking flush and/or close.
Just to confirm your experiences: Does the copied file that this creates for you have a size of zero bytes?
[ May 11, 2002: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Originally posted by jyothi abraham:
(please comment out the line in for loop;
size = -1)

I'm not sure what you mean. That line is not in the for loop and to use that identifier in the for loop, it needs to be declared and initialized.
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
if(size !=4096) break;
should be something more like
if(size == -1) break;
[ May 11, 2002: Message edited by: David Weitzman ]
jyothi abraham
Ranch Hand

Joined: Aug 14, 2001
Posts: 46
Thank you.Its working.Firstly I checked with
a tiny picture of 2kb.I think that was the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: file created,but nothing inside