File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes write to f file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "write to f file" Watch "write to f file" New topic
Author

write to f file

abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635


what does FileWriter in this code?
What does BufferedWriter in this code?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Sep 06, 2007
Posts: 635
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

Joined: Sep 29, 2008
Posts: 12617

Sure you do. Streams, too.

http://www.cs.cf.ac.uk/Dave/C/node18.html#SECTION001820000000000000000
abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Oct 27, 2005
Posts: 19697
    
  20

There is a special FILE type in C for that. FileInputStream probably uses the native calls like fopen and fclose. See stdio.h.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635
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

Joined: Oct 27, 2005
Posts: 19697
    
  20

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

Joined: Oct 13, 2005
Posts: 38910
    
  23
I think this discussion would sit better on our Streams forum. Moving thread.
 
 
subject: write to f file