File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

write to f file

 
abalfazl hossein
Ranch Hand
Posts: 635
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


what does FileWriter in this code?
What does BufferedWriter in this code?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you notice that the words FileWriter and BufferedWriter are underlined?

They're links to their Javadocs, which explain what they are. After reading that, if you have specific questions, feel free to follow up!
 
abalfazl hossein
Ranch Hand
Posts: 635
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileWriter is meant for writing streams of characters


what is stream?

May you explain about the mechanism Of write or read files in Java?

Why buffer is used?

In C, we don't use it
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure you do. Streams, too.

http://www.cs.cf.ac.uk/Dave/C/node18.html#SECTION001820000000000000000
 
abalfazl hossein
Ranch Hand
Posts: 635
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain in more details internal mechanism of stream, I want to know how stream works?I want to know while this line runs:



What happened behind the scene?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you aware you can look at the source code? The docs sum it up; for general stream info you'll have to jump into native code. Perhaps you could look at how files are handled in an open-source C library.
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a special FILE type in C for that. FileInputStream probably uses the native calls like fopen and fclose. See stdio.h.
 
abalfazl hossein
Ranch Hand
Posts: 635
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Streams attach data to objects. Data flows in streams. An input data stream is needed to connect
data from the keyboard to your program. The connection to the keyboard is System.in. An output
data stream is needed to send data to from your program to the computer screen



I read this in tutorial

When I compare this with:
http://www.cs.cf.ac.uk/Dave/C/node18.html#SECTION001820000000000000000

A Stream is a file or a physical device (e.g. printer or monitor) which is manipulated with a pointer to the stream.


Still don't know relation between stream and file!
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A stream is just that - a stream (or sequence) of bytes. Although files can be access randomly (in Java using RandomAccessFile), FileInputStream still gives you a stream - byte 1 first, then byte 2, etc.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this discussion would sit better on our Streams forum. Moving thread.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic