انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

File in Java - 02

الكلية كلية تكنولوجيا المعلومات     القسم قسم شبكات المعلومات     المرحلة 3
أستاذ المادة مهدي عبادي مانع الموسوي       16/12/2016 08:57:25
1. Data Within Streams
Java technology supports two types of streams: character and byte.
Input and output of character data is handled (implemented) by subclass readers and writers.
Input and output of byte data is handled (implemented) by subclass inputStream and OutputStream


3.1. Byte Streams
The following sections describe the fundamental byte stream

3.1.1 The InputStream Methods
The following three methods provide access to the data from the input stream:
The three basic read methods are:
int read()
// return an int from input stream, which contains either a byte read from the stream or a -1
It means The java.io.InputStream.read() method reads the next byte of the data from the the input stream and returns int in the range of 0 to 255. If no byte is available because the end of the stream has been reached, the returned value is -1.
int read(byte[] buffer)
// read the stream into a byte array and return the number of bytes read
int read(byte[] buffer, int offset, int length)
// read the stream into a byte array and return the number of bytes read , the two int arguments in the third method indicate a sub range in the target array that needs to be filled

Other methods include:
void close()
//it closes the stream
long skip(long n)
//this method discards the specified number of bytes from the stream.
3.1.2 The OutputStream Methods
These methods write to the output of stream:
The three basic write methods are:
void write(int c)//
void write(byte[] buffer)
void write(byte[] buffer, int offset, int length)

• Other methods include:
void close()
void flush()// output stream uses it to force write when the write accumulate before committing


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .