• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file created,but nothing inside

 
jyothi abraham
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be sure to close() and/or flush() the OutputStream
 
jyothi abraham
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used out.flush() and out.close(),but no desired
result.
(please comment out the line in for loop;
size = -1)
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.Its working.Firstly I checked with
a tiny picture of 2kb.I think that was the problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic