• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

jpeg and mp3 doubt

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote a small application i.e transfer files and directories from source to destination paths.I just use BufferedReader class and PrintWriter class but i got only .txt files were copied.how can i transfer any type of files like mp3,jpg.....
 
Sheriff
Posts: 22716
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just use InputStream and OutputStream, possible the Buffered versions.

Next, don't read lines but instead chunks. The basics, which works with every type of InputStream and OutputStream:

You can also choose to read byte per byte, but usually the above approach is a lot faster.

Don't be put off by the assignment in the while statement. It's a shorter way of writing the following:
 
vasu chowdary
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do you mean jpeg file can be read and write using stream classes like text files?
 
vasu chowdary
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks rob it is working
 
Rob Spoor
Sheriff
Posts: 22716
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vasu chowdary:
do you mean jpeg file can be read and write using stream classes like text files?


The Stream classes can be used for any type of file, because it just reads and writes the bytes of the file. It doesn't look at what those files mean.

For text files, the Reader and Writer classes are better since they are able to convert the bytes into actual characters. While for simple ASCII text files you won't notice much difference, you will feel differently when reading unicode text files.
reply
    Bookmark Topic Watch Topic
  • New Topic