天天看點

Java IO TutorialJava IO Tutorial

Java Io 

1

<a target="_blank" href="http://tutorials.jenkov.com/java-io/index.html">Java IO Tutorial</a>

2

<a target="_blank" href="http://tutorials.jenkov.com/java-io/overview.html">Java IO Overview</a>

3

<a target="_blank" href="http://tutorials.jenkov.com/java-io/files.html">Java IO: Files</a>

4

<a target="_blank" href="http://tutorials.jenkov.com/java-io/pipes.html">Java IO: Pipes</a>

5

<a target="_blank" href="http://tutorials.jenkov.com/java-io/networking.html">Java IO: Networking</a>

6

<a target="_blank" href="http://tutorials.jenkov.com/java-io/arrays.html">Java IO: Byte &amp; Char Arrays</a>

7

<a target="_blank" href="http://tutorials.jenkov.com/java-io/system-in-out-error.html">Java IO: System.in, System.out, and System.error</a>

8

<a target="_blank" href="http://tutorials.jenkov.com/java-io/streams.html">Java IO: Streams</a>

9

<a target="_blank" href="http://tutorials.jenkov.com/java-io/input-parsing.html">Java IO: Input Parsing</a>

10

<a target="_blank" href="http://tutorials.jenkov.com/java-io/readers-writers.html">Java IO: Readers and Writers</a>

11

<a target="_blank" href="http://tutorials.jenkov.com/java-io/concurrent-io.html">Java IO: Concurrent IO</a>

12

<a target="_blank" href="http://tutorials.jenkov.com/java-io/io-exception-handling.html">Java IO: Exception Handling</a>

13

<a target="_blank" href="http://tutorials.jenkov.com/java-io/inputstream.html">Java IO: InputStream</a>

14

<a target="_blank" href="http://tutorials.jenkov.com/java-io/outputstream.html">Java IO: OutputStream</a>

15

<a target="_blank" href="http://tutorials.jenkov.com/java-io/fileinputstream.html">Java IO: FileInputStream</a>

16

<a target="_blank" href="http://tutorials.jenkov.com/java-io/fileoutputstream.html">Java IO: FileOutputStream</a>

17

<a target="_blank" href="http://tutorials.jenkov.com/java-io/randomaccessfile.html">Java IO: RandomAccessFile</a>

18

<a target="_blank" href="http://tutorials.jenkov.com/java-io/file.html">Java IO: File</a>

19

<a target="_blank" href="http://tutorials.jenkov.com/java-io/pipedinputstream.html">Java IO: PipedInputStream</a>

20

<a target="_blank" href="http://tutorials.jenkov.com/java-io/pipedoutputstream.html">Java IO: PipedOutputStream</a>

21

<a target="_blank" href="http://tutorials.jenkov.com/java-io/bytearrayinputstream.html">Java IO: ByteArrayInputStream</a>

22

<a target="_blank" href="http://tutorials.jenkov.com/java-io/bytearrayoutputstream.html">Java IO: ByteArrayOutputStream</a>

23

<a target="_blank" href="http://tutorials.jenkov.com/java-io/filterinputstream.html">Java IO: FilterInputStream</a>

24

<a target="_blank" href="http://tutorials.jenkov.com/java-io/filteroutputstream.html">Java IO: FilterOutputStream</a>

25

<a target="_blank" href="http://tutorials.jenkov.com/java-io/bufferedinputstream.html">Java IO: BufferedInputStream</a>

26

<a target="_blank" href="http://tutorials.jenkov.com/java-io/bufferedoutputstream.html">Java IO: BufferedOutputStream</a>

27

<a target="_blank" href="http://tutorials.jenkov.com/java-io/pushbackinputstream.html">Java IO: PushbackInputStream</a>

28

<a target="_blank" href="http://tutorials.jenkov.com/java-io/sequenceinputstream.html">Java IO: SequenceInputStream</a>

29

<a target="_blank" href="http://tutorials.jenkov.com/java-io/datainputstream.html">Java IO: DataInputStream</a>

30

<a target="_blank" href="http://tutorials.jenkov.com/java-io/dataoutputstream.html">Java IO: DataOutputStream</a>

31

<a target="_blank" href="http://tutorials.jenkov.com/java-io/printstream.html">Java IO: PrintStream</a>

32

<a target="_blank" href="http://tutorials.jenkov.com/java-io/objectinputstream.html">Java IO: ObjectInputStream</a>

33

<a target="_blank" href="http://tutorials.jenkov.com/java-io/objectoutputstream.html">Java IO: ObjectOutputStream</a>

34

<a target="_blank" href="http://tutorials.jenkov.com/java-io/serializable.html">Java IO: Serializable</a>

35

<a target="_blank" href="http://tutorials.jenkov.com/java-io/reader.html">Java IO: Reader</a>

36

<a target="_blank" href="http://tutorials.jenkov.com/java-io/writer.html">Java IO: Writer</a>

37

<a target="_blank" href="http://tutorials.jenkov.com/java-io/inputstreamreader.html">Java IO: InputStreamReader</a>

38

<a target="_blank" href="http://tutorials.jenkov.com/java-io/outputstreamwriter.html">Java IO: OutputStreamWriter</a>

39

<a target="_blank" href="http://tutorials.jenkov.com/java-io/filereader.html">Java IO: FileReader</a>

40

<a target="_blank" href="http://tutorials.jenkov.com/java-io/filewriter.html">Java IO: FileWriter</a>

41

<a target="_blank" href="http://tutorials.jenkov.com/java-io/pipedreader.html">Java IO: PipedReader</a>

42

<a target="_blank" href="http://tutorials.jenkov.com/java-io/pipedwriter.html">Java IO: PipedWriter</a>

43

<a target="_blank" href="http://tutorials.jenkov.com/java-io/chararrayreader.html">Java IO: CharArrayReader</a>

44

<a target="_blank" href="http://tutorials.jenkov.com/java-io/chararraywriter.html">Java IO: CharArrayWriter</a>

45

<a target="_blank" href="http://tutorials.jenkov.com/java-io/bufferedreader.html">Java IO: BufferedReader</a>

46

<a target="_blank" href="http://tutorials.jenkov.com/java-io/bufferedwriter.html">Java IO: BufferedWriter</a>

47

<a target="_blank" href="http://tutorials.jenkov.com/java-io/filterreader.html">Java IO: FilterReader</a>

48

<a target="_blank" href="http://tutorials.jenkov.com/java-io/filterwriter.html">Java IO: FilterWriter</a>

49

<a target="_blank" href="http://tutorials.jenkov.com/java-io/pushbackreader.html">Java IO: PushbackReader</a>

50

<a target="_blank" href="http://tutorials.jenkov.com/java-io/linenumberreader.html">Java IO: LineNumberReader</a>

51

<a target="_blank" href="http://tutorials.jenkov.com/java-io/streamtokenizer.html">Java IO: StreamTokenizer</a>

52

<a target="_blank" href="http://tutorials.jenkov.com/java-io/printwriter.html">Java IO: PrintWriter</a>

53

<a target="_blank" href="http://tutorials.jenkov.com/java-io/stringreader.html">Java IO: StringReader</a>

54

<a target="_blank" href="http://tutorials.jenkov.com/java-io:-stringwriter.html">Java IO: StringWriter</a>

Java IO TutorialJava IO Tutorial

Rate article:

&lt;iframe frameborder="0" hspace="0" marginheight="0" marginwidth="0" scrolling="no" tabindex="0" vspace="0" width="100%" id="I0_1416445511063" name="I0_1416445511063" src="https://apis.google.com/se/0/_/+1/fastbutton?usegapi=1&amp;amp;origin=http%3A%2F%2Ftutorials.jenkov.com&amp;amp;url=http%3A%2F%2Ftutorials.jenkov.com%2Fjava-io%2Findex.html&amp;amp;gsrc=3p&amp;amp;ic=1&amp;amp;jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.zh_CN.0KI2lcOUxJ0.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Ft%3Dzcms%2Frs%3DAGLTcCPnLWTRWXjQ3yHtGTFSsUVyRcOV5g#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh&amp;amp;id=I0_1416445511063&amp;amp;parent=http%3A%2F%2Ftutorials.jenkov.com&amp;amp;pfname=&amp;amp;rpctoken=30215823" data-gapiattached="true" style="position: absolute; top: -10000px; width: 450px; margin: 0px; border-style: none;"&gt;&lt;/iframe&gt;

Share article:

&lt;iframe frameborder="0" hspace="0" marginheight="0" marginwidth="0" scrolling="no" tabindex="0" vspace="0" width="100%" id="I1_1416445511067" name="I1_1416445511067" src="https://apis.google.com/se/0/_/+1/sharebutton?plusShare=true&amp;amp;usegapi=1&amp;amp;action=share&amp;amp;height=24&amp;amp;annotation=none&amp;amp;origin=http%3A%2F%2Ftutorials.jenkov.com&amp;amp;url=http%3A%2F%2Ftutorials.jenkov.com%2Fjava-io%2Findex.html&amp;amp;gsrc=3p&amp;amp;ic=1&amp;amp;jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.zh_CN.0KI2lcOUxJ0.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Ft%3Dzcms%2Frs%3DAGLTcCPnLWTRWXjQ3yHtGTFSsUVyRcOV5g#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh%2Conload&amp;amp;id=I1_1416445511067&amp;amp;parent=http%3A%2F%2Ftutorials.jenkov.com&amp;amp;pfname=&amp;amp;rpctoken=26902609" data-gapiattached="true" style="position: absolute; top: -10000px; width: 450px; margin: 0px; border-style: none;"&gt;&lt;/iframe&gt;

<a target="_blank" href="https://twitter.com/share">Tweet</a>

Java IO is an API that comes with Java which is targeted at reading and writing data (input and output). Most applications need to process some input and produce some output based on that input. For instance, read data from a file or over network, and write to a file or write a response back over the network.

The Java IO API is located in the Java IO package (<code>java.io</code>). If you look at the Java IO classes in the <code>java.io</code>package the vast amount of choices can be rather confusing. What is the purpose of all these classes? Which one should you choose for a given task? How do you create your own classes to plugin? etc. The purpose of this tutorial is to try to give you an overview of how all these classes are grouped, and the purpose behind them, so you don't have to wonder whether you chose the right class, or whether a class already exists for your purpose.

The tutorial starts by giving you a solid overview of how the Java IO APIs work, and how you are supposed to use them. After that the tutorial switches to covering the core classes in the Java IO API.

The coverage of the classes in this tutorial is not just an API listing. It's more than just a class listing (you can get that from Sun's official Java Doc's). Rather each text is a short introduction to the class, its purpose, and a few examples of how to use it. In other words, some of the stuff you don't find in Sun's official Java Doc's.

The first version of this Java IO tutorial was written based on Java 5, but the classes work pretty much the same all the way up to Java 8 which is the latest version of Java at the time of writing.

<a target="_blank" href="http://tutorials.jenkov.com/java-io/overview.html">Next:   Java IO Overview</a>