SlideShare a Scribd company logo
1 
Java IO Stream
2 
Noi dung 
 Luông nhap xuât là gì? 
 Các loi luông 
 Phân câp lp luông 
 Dùng Stream e iêu khien luông nhap xuât. 
 Byte streams 
 Character streams 
 Buffered streams 
 Standard I/O streams 
 Data streams 
 Object streams 
 Lp File
3 
Khái niem luông? 
 Luông là mot “dòng ch
y” ca d
lieu ưc gan vi 
các thiêt b vào ra. 
 Hai loi luông: 
 Luông nhap: Gan vi các thiêt b nhap như bàn phím, máy 
scan, file... 
 Luông xuât: Gan vi các thiêt b xuât như màn hình, máy 
in, file... 
 Viec x lý vào ra thông qua luông giúp cho lap trình 
viên không ph
i quan tâm ên b
n chât ca thiêt b 
vào ra.
4 
Input Stream 
 Chương trình s dng input stream e c 
d
lieu t nguôn.
5 
Output Stream 
 Chương trình s dng output stream e ghi 
d
lieu xuông ích.
6 
Các loi luông 
 Character and Byte Streams 
 Character vs. Byte 
 Input and Output Streams 
 Da trên nguôn và ích 
 Node and Filter Streams 
 Khi d
lieu trong luông ưc thao tác hoac 
chuyen oi.
7 
Character and Byte Streams 
 Byte streams 
 Cho d
lieu dng nh phân 
 Nh
ng lp gôc cho các byte stream: 
 Lp InputStream 
 Lp OutputStream 
 C
 2 lp là tru tưng (Abstract) 
 Character streams 
 Cho các ký t Unicode 
 Nh
ng lp gôc cho character stream: 
 Lp Reader 
 Lp Writer 
 C
 2 lp là tru tưng (Abstract)
8 
Input and Output Streams 
 Input or source streams 
 Có the c t nh
ng nguôn này. 
 Nh
ng lp gôc ca tât c
 các input stream: 
 Lp InputStream 
 Lp Reader 
 Output or destination streams 
 Có the ghi xuông nh
ng luông này 
 Nh
ng lp gôc ca tât c
 các output stream: 
 Lp OutputStream 
 Lp Writer
9 
Node and Filter Streams 
 Node streams (Data sink stream) 
 Cha nh
ng chc nang cơ b
n cho viec c và ghi t mot 
v trí xác nh. 
 Các loi node stream bao gôm file, bo nh và pipe 
 Filter streams (Processing stream) 
 Luông lc có kh
 nang kêt nôi vi các luông khác và x lý 
d
lieu “theo cách riêng” ca nó. 
 FilterInputStream và FilterOutputStream là 2 lp luông lc 
cơ b
n.
10 
Hierarchy of classes and interfaces 
Object 
File FileDescriptor 
DataInput RandomAccessFile DataOutput 
DataInput 
Stream 
Buffered 
InputStream 
LineNumber 
InputStream 
PushBack 
InputStream 
Filter 
InputStream 
InputStream 
ByteArray 
InputStream 
FileInput 
Stream 
OutputStream 
FileOutput 
Stream 
Filter 
OutputStream 
ByteArray 
OutputStream 
Buffered 
OutputStream 
DataOutput 
Stream 
Print 
Stream
11 
Hierarchy of classes and interfaces Object 
Reader 
Piped 
Reader 
LineNumberReader FileReader 
PushbackReader 
Filter 
Reader 
Buffered 
Reader 
CharArray 
Reader 
Writer 
CharArray 
Writer 
OutputStream 
Writer 
Print 
Writer 
Print 
Stream 
InputStream 
Reader 
String 
Reader 
Filter 
Writer 
Buffered 
Writer 
Piped 
Writer 
String 
Writer
12 
Abstract Classes 
 InputStream  OutputStream 
 Reader  Writer
13 
InputStream Abstract Class 
 public abstract int read() throws IOException 
c mot byte kê tiêp ca d
lieu t luông. 
 public int read(byte[] bBuf) throws IOException 
c mot sô byte d
lieu t luông và lưu vào m
ng byte bBuf. 
 public int read(byte[] cBuf, int offset, int length) throws IOException 
c length byte d
lieu t luông và lưu vào m
ng byte cBuf bat âu ti v 
trí offset. 
 public void close() throws IOException 
óng nguôn. Gi nh
ng phương thc khác sau khi ó nguôn se gây ra loi 
IOException 
 public int mark(int readAheadLimit) throws IOException 
ánh dâu v trí hien hành ca stream. Sau khi ánh dâu, gi reset() se 
nh li v trí ca luông ên iem này. Không ph
i tât c
 luông byte –input ho 
tr cho thao tác này. 
 public int markSupported() 
Ch ra luông có ho tr thao tác mark và reset hay không
14 
Node InputStream Classes 
 FileInputStream 
 c các byte t file 
 ByteArrayInputStream 
 Thc thi mot buffer mà nó cha các byte, mà nó có the 
ưc c t nguôn. 
 PipedInputStream 
 Nên ưc liên kêt vi PipedOutputStream. Nh
ng 
luông này ưc s dng b#i 2 luông. Trong ó mot cái là 
c d
lieu t nguôn trong khi nh
ng cái khác thì ghi 
xuông PipedOutputStream tương ng.
15 
Filter InputStream Classes 
 BufferedInputStream 
 Mot class con ca FilterInputStream cho phép at vùng em cho input e 
c các byte d
lieu mot cách hieu qu
. 
 FilterInputStream 
 For reading filtered byte streams, which may transform the basic source data 
along the way and provide additional functionalities. 
 ObjectInputStream 
 Used for object serialization. Deserializes objects and previuosly written 
using an ObjectOutputStream. 
 DataInputStream 
 A subclass of FilterInputStream that lets an application read Java primitive 
data from underlying inputstream in a machine-independent way. 
 LineNumberInputStream 
 A subclass of FilterInputStream that allows tracking of the current line 
number. 
 PushbackInputStream 
 A subclass of FilterInputStream class that allows bytes to be pushed back or 
unread into the stream
16 
Lp tru tng OutputStream 
 public void write(int b) throws IOException 
Ghi giá tr b xác nh theo dng byte xuông output stream 
 public void write(byte[] b) throws IOException 
Lưu noi dung ca m
ng byte b xuông luông 
 public void write(byte[] b, int off, int len) throws 
IOException 
Lưu len byte ca m
ng byte b xuông luông, bat âu t v trí off ca m
ng 
 public void close() throws IOException 
óng nguôn. Gi nh
ng phương thc khác liên quan ên nguôn này sau khi gi 
close se gây ra loi IOException. 
 public void flush() throws IOException 
flushes the stream.(ví d: Nh
ng byte ưc lưu trong buffer ngay lap tc ưc 
ghi xuông ích)
17 
Node OutputStream Classes 
 FileOuputStream 
 For writing bytes to a file 
 ByteArrayOutputStream 
 Implements a buffer that contains bytes, which may be 
written to the stream 
 PipedOutputStream 
 Should be connected to a PipedInputStream. These 
streams are typically used by two threads wherein one of 
these threads writes data to this stream while the other 
thread reads from the corresponding PipeInputStream.
18 
Filter OutputStream Classes 
 BufferedOutputStream 
 A subclass of FilterOutputStream that allows buffering of output in order to 
provide for the efficient writing of bytes. Allows writing of bytes to the 
underlying output stream without necessarily causing a call to underlying 
system for each byte written. 
 FilterOutputStream 
 For writing filtered byte streams, which may transform the basic source of 
data along the way and provide additional functionalities. 
 ObjectOutputStream 
 Used for object serialization. Serializes object and primitve data to 
OuputStream. 
 DataOutputStream 
 A subclass of FilterOutputStream that lets an application write Java primitive 
data to underlying output stream in machine-independent way. 
 PrintStream 
 A subclass of FilteOutputStream that provides capability for printing 
representations of various data values conveniently.
19 
The Reader Class: Methods 
 public int read() throws IOException 
 c mot ký t 
 public int read(char[] cbuf) throws IOException 
 c nh
ng ký t và lưu chúng vào m
ng cbuf 
 public abstract int read(char[] cbuf, int off, int len) throws 
IOException 
 c len ký t và lưu chúng vào tron m
ng cbuf, bat âu ti v trí off ca m
ng 
 public abstract void close() throws IOException 
 óng luông. Gi nh
ng phương thc Reader khác ca sau khi gi close se gây ra loi IOException 
 public void mark(int readAheadLimit) throws IOException 
 ánh dâu v trí hien hành ca stream. Sau khi ánh dâu, gi reset() e th at li v trí luông ti 
iem này. Không ph
i tât c
 character-input êu ho tr thao tác này 
 public boolean markSupported() 
 Ch ra luông có ho tr thao tác này hay không. Mac nh là không ho tr. 
 public void reset() throws IOException 
 at li v trí luông ti v trí ánh dâu lân cuôi
20 
Node Reader Classes 
 FileReader 
 Cho viec c t file 
 CharArrayReader 
 Thc thi mot vùng em ký t có the ưc c 
 StringReader 
 Cho viec c t nguôn string 
 PipedReader 
 Dùng theo cap (tương ng vi PipedWriter) bang 
2 luông mà chúng có the liên lc vi nhau.Mot 
trong nh
ng cái luông c các ký t.
21 
Filter Reader Classes 
 BufferedReader 
 Allows buffering of characters in order to provide for efficient reading 
of characters, arrays, and lines 
 FilterReader 
 For reading filtered character streams 
 InputStreamReader 
 Converts read bytes to characters 
 LineNumberReader 
 A subclass of BufferedReader class that able to keep track of line 
numbers. 
 PushbackReader 
 A subclass of the FilterReader class that allows character to pushed 
back or unread into the stream.
22 
The Writer Class: Methods 
 public void write(int c) throws IOException 
Ghi mot ký t ơn ưc the hien bang sô nguyên. Ví d: ‘A’ là ưc ghi la 
write(65) 
 public void write(char[] cbuf) throws IOException 
Ghi noi dung ca m
ng ký t cbuf xuông luông 
 public abstract void write(char[] cbuf, int off, int len) 
throws IOException 
Ghi mot m
ng ký t cbuf vi chiêu dài là len, bat âu là v trí off 
 public void write(String str) throws IOException 
Ghi mot chuoi str 
 public void write(String str, int off, int len) throws 
IOException 
Ghi mot chuoi str vi chiêu dài là len, bat âu t v trí off 
 public abstract void flush() throws IOException 
ay d
lieu xuông ích ên. 
 public abstract void close() throws IOException 
óng luông.

More Related Content

What's hot

Java Input and Output
Java Input and OutputJava Input and Output
Java Input and Output
Ducat India
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
Shahjahan Samoon
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
Ravi Chythanya
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
Anton Keks
 
Handling I/O in Java
Handling I/O in JavaHandling I/O in Java
Handling I/O in Java
Hiranya Jayathilaka
 
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثامنة
شرح مقرر البرمجة 2   لغة جافا - الوحدة الثامنةشرح مقرر البرمجة 2   لغة جافا - الوحدة الثامنة
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثامنة
جامعة القدس المفتوحة
 
IO In Java
IO In JavaIO In Java
IO In Java
parag
 
Java Streams
Java StreamsJava Streams
Java Streams
M Vishnuvardhan Reddy
 
IO and serialization
IO and serializationIO and serialization
IO and serialization
backdoor
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
Hamid Ghorbani
 
Java I/O
Java I/OJava I/O
Java I/O
Jayant Dalvi
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
teach4uin
 
Io Streams
Io StreamsIo Streams
Io Streams
leminhvuong
 
Chapter28 data-file-handling
Chapter28 data-file-handlingChapter28 data-file-handling
Chapter28 data-file-handling
Deepak Singh
 
Files & IO in Java
Files & IO in JavaFiles & IO in Java
Files & IO in Java
CIB Egypt
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?
kanchanmahajan23
 
Filehandling
FilehandlingFilehandling
Filehandling
Muhammad Fahad
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
Shyam Gupta
 
Java program file I/O
Java program file I/OJava program file I/O
Java program file I/O
Nem Sothea
 
Javaiostream
JavaiostreamJavaiostream
Javaiostream
Tien Nguyen
 

What's hot (20)

Java Input and Output
Java Input and OutputJava Input and Output
Java Input and Output
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
 
Handling I/O in Java
Handling I/O in JavaHandling I/O in Java
Handling I/O in Java
 
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثامنة
شرح مقرر البرمجة 2   لغة جافا - الوحدة الثامنةشرح مقرر البرمجة 2   لغة جافا - الوحدة الثامنة
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثامنة
 
IO In Java
IO In JavaIO In Java
IO In Java
 
Java Streams
Java StreamsJava Streams
Java Streams
 
IO and serialization
IO and serializationIO and serialization
IO and serialization
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Java I/O
Java I/OJava I/O
Java I/O
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
Io Streams
Io StreamsIo Streams
Io Streams
 
Chapter28 data-file-handling
Chapter28 data-file-handlingChapter28 data-file-handling
Chapter28 data-file-handling
 
Files & IO in Java
Files & IO in JavaFiles & IO in Java
Files & IO in Java
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?
 
Filehandling
FilehandlingFilehandling
Filehandling
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
 
Java program file I/O
Java program file I/OJava program file I/O
Java program file I/O
 
Javaiostream
JavaiostreamJavaiostream
Javaiostream
 

Similar to Nhap xuat trong java

UNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf NotesUNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf Notes
SakkaravarthiS1
 
File Input and output.pptx
File Input  and output.pptxFile Input  and output.pptx
File Input and output.pptx
cherryreddygannu
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptx
ssuser9d7049
 
Java Tutorial Lab 6
Java Tutorial Lab 6Java Tutorial Lab 6
Java Tutorial Lab 6
Berk Soysal
 
Computer science input and output BASICS.pptx
Computer science input and output BASICS.pptxComputer science input and output BASICS.pptx
Computer science input and output BASICS.pptx
RathanMB
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
siragezeynu
 
Unit IV Notes.docx
Unit IV Notes.docxUnit IV Notes.docx
Unit IV Notes.docx
GayathriRHICETCSESTA
 
Using Input Output
Using Input OutputUsing Input Output
Using Input Output
raksharao
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input Output
Bharat17485
 
Java session14
Java session14Java session14
Java session14
Niit Care
 
Md121 streams
Md121 streamsMd121 streams
Md121 streams
Rakesh Madugula
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?
kanchanmahajan23
 
THE IO LIBRARY in C++
THE IO LIBRARY in C++THE IO LIBRARY in C++
THE IO LIBRARY in C++
Prof Ansari
 
Javaiostream
JavaiostreamJavaiostream
Javaiostream
Manav Prasad
 
Class data outputstream
Class data outputstreamClass data outputstream
Class data outputstream
myrajendra
 
CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptx
SadhilAggarwal
 
javaiostream
javaiostreamjavaiostream
javaiostream
Arjun Shanka
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
People Strategists
 
Java - File Input Output Concepts
Java - File Input Output ConceptsJava - File Input Output Concepts
Java - File Input Output Concepts
Victer Paul
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)
Om Ganesh
 

Similar to Nhap xuat trong java (20)

UNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf NotesUNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf Notes
 
File Input and output.pptx
File Input  and output.pptxFile Input  and output.pptx
File Input and output.pptx
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptx
 
Java Tutorial Lab 6
Java Tutorial Lab 6Java Tutorial Lab 6
Java Tutorial Lab 6
 
Computer science input and output BASICS.pptx
Computer science input and output BASICS.pptxComputer science input and output BASICS.pptx
Computer science input and output BASICS.pptx
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Unit IV Notes.docx
Unit IV Notes.docxUnit IV Notes.docx
Unit IV Notes.docx
 
Using Input Output
Using Input OutputUsing Input Output
Using Input Output
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input Output
 
Java session14
Java session14Java session14
Java session14
 
Md121 streams
Md121 streamsMd121 streams
Md121 streams
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?
 
THE IO LIBRARY in C++
THE IO LIBRARY in C++THE IO LIBRARY in C++
THE IO LIBRARY in C++
 
Javaiostream
JavaiostreamJavaiostream
Javaiostream
 
Class data outputstream
Class data outputstreamClass data outputstream
Class data outputstream
 
CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptx
 
javaiostream
javaiostreamjavaiostream
javaiostream
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
 
Java - File Input Output Concepts
Java - File Input Output ConceptsJava - File Input Output Concepts
Java - File Input Output Concepts
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)
 

Recently uploaded

HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
Techgropse Pvt.Ltd.
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 

Recently uploaded (20)

HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 

Nhap xuat trong java

  • 1. 1 Java IO Stream
  • 2. 2 Noi dung Luông nhap xuât là gì? Các loi luông Phân câp lp luông Dùng Stream e iêu khien luông nhap xuât. Byte streams Character streams Buffered streams Standard I/O streams Data streams Object streams Lp File
  • 3. 3 Khái niem luông? Luông là mot “dòng ch y” ca d
  • 4. lieu ưc gan vi các thiêt b vào ra. Hai loi luông: Luông nhap: Gan vi các thiêt b nhap như bàn phím, máy scan, file... Luông xuât: Gan vi các thiêt b xuât như màn hình, máy in, file... Viec x lý vào ra thông qua luông giúp cho lap trình viên không ph i quan tâm ên b n chât ca thiêt b vào ra.
  • 5. 4 Input Stream Chương trình s dng input stream e c d
  • 7. 5 Output Stream Chương trình s dng output stream e ghi d
  • 9. 6 Các loi luông Character and Byte Streams Character vs. Byte Input and Output Streams Da trên nguôn và ích Node and Filter Streams Khi d
  • 10. lieu trong luông ưc thao tác hoac chuyen oi.
  • 11. 7 Character and Byte Streams Byte streams Cho d
  • 12. lieu dng nh phân Nh
  • 13. ng lp gôc cho các byte stream: Lp InputStream Lp OutputStream C 2 lp là tru tưng (Abstract) Character streams Cho các ký t Unicode Nh
  • 14. ng lp gôc cho character stream: Lp Reader Lp Writer C 2 lp là tru tưng (Abstract)
  • 15. 8 Input and Output Streams Input or source streams Có the c t nh
  • 17. ng lp gôc ca tât c các input stream: Lp InputStream Lp Reader Output or destination streams Có the ghi xuông nh
  • 19. ng lp gôc ca tât c các output stream: Lp OutputStream Lp Writer
  • 20. 9 Node and Filter Streams Node streams (Data sink stream) Cha nh
  • 21. ng chc nang cơ b n cho viec c và ghi t mot v trí xác nh. Các loi node stream bao gôm file, bo nh và pipe Filter streams (Processing stream) Luông lc có kh nang kêt nôi vi các luông khác và x lý d
  • 22. lieu “theo cách riêng” ca nó. FilterInputStream và FilterOutputStream là 2 lp luông lc cơ b n.
  • 23. 10 Hierarchy of classes and interfaces Object File FileDescriptor DataInput RandomAccessFile DataOutput DataInput Stream Buffered InputStream LineNumber InputStream PushBack InputStream Filter InputStream InputStream ByteArray InputStream FileInput Stream OutputStream FileOutput Stream Filter OutputStream ByteArray OutputStream Buffered OutputStream DataOutput Stream Print Stream
  • 24. 11 Hierarchy of classes and interfaces Object Reader Piped Reader LineNumberReader FileReader PushbackReader Filter Reader Buffered Reader CharArray Reader Writer CharArray Writer OutputStream Writer Print Writer Print Stream InputStream Reader String Reader Filter Writer Buffered Writer Piped Writer String Writer
  • 25. 12 Abstract Classes InputStream OutputStream Reader Writer
  • 26. 13 InputStream Abstract Class public abstract int read() throws IOException c mot byte kê tiêp ca d
  • 27. lieu t luông. public int read(byte[] bBuf) throws IOException c mot sô byte d
  • 28. lieu t luông và lưu vào m ng byte bBuf. public int read(byte[] cBuf, int offset, int length) throws IOException c length byte d
  • 29. lieu t luông và lưu vào m ng byte cBuf bat âu ti v trí offset. public void close() throws IOException óng nguôn. Gi nh
  • 30. ng phương thc khác sau khi ó nguôn se gây ra loi IOException public int mark(int readAheadLimit) throws IOException ánh dâu v trí hien hành ca stream. Sau khi ánh dâu, gi reset() se nh li v trí ca luông ên iem này. Không ph i tât c luông byte –input ho tr cho thao tác này. public int markSupported() Ch ra luông có ho tr thao tác mark và reset hay không
  • 31. 14 Node InputStream Classes FileInputStream c các byte t file ByteArrayInputStream Thc thi mot buffer mà nó cha các byte, mà nó có the ưc c t nguôn. PipedInputStream Nên ưc liên kêt vi PipedOutputStream. Nh
  • 32. ng luông này ưc s dng b#i 2 luông. Trong ó mot cái là c d
  • 33. lieu t nguôn trong khi nh
  • 34. ng cái khác thì ghi xuông PipedOutputStream tương ng.
  • 35. 15 Filter InputStream Classes BufferedInputStream Mot class con ca FilterInputStream cho phép at vùng em cho input e c các byte d
  • 36. lieu mot cách hieu qu . FilterInputStream For reading filtered byte streams, which may transform the basic source data along the way and provide additional functionalities. ObjectInputStream Used for object serialization. Deserializes objects and previuosly written using an ObjectOutputStream. DataInputStream A subclass of FilterInputStream that lets an application read Java primitive data from underlying inputstream in a machine-independent way. LineNumberInputStream A subclass of FilterInputStream that allows tracking of the current line number. PushbackInputStream A subclass of FilterInputStream class that allows bytes to be pushed back or unread into the stream
  • 37. 16 Lp tru tng OutputStream public void write(int b) throws IOException Ghi giá tr b xác nh theo dng byte xuông output stream public void write(byte[] b) throws IOException Lưu noi dung ca m ng byte b xuông luông public void write(byte[] b, int off, int len) throws IOException Lưu len byte ca m ng byte b xuông luông, bat âu t v trí off ca m ng public void close() throws IOException óng nguôn. Gi nh
  • 38. ng phương thc khác liên quan ên nguôn này sau khi gi close se gây ra loi IOException. public void flush() throws IOException flushes the stream.(ví d: Nh
  • 39. ng byte ưc lưu trong buffer ngay lap tc ưc ghi xuông ích)
  • 40. 17 Node OutputStream Classes FileOuputStream For writing bytes to a file ByteArrayOutputStream Implements a buffer that contains bytes, which may be written to the stream PipedOutputStream Should be connected to a PipedInputStream. These streams are typically used by two threads wherein one of these threads writes data to this stream while the other thread reads from the corresponding PipeInputStream.
  • 41. 18 Filter OutputStream Classes BufferedOutputStream A subclass of FilterOutputStream that allows buffering of output in order to provide for the efficient writing of bytes. Allows writing of bytes to the underlying output stream without necessarily causing a call to underlying system for each byte written. FilterOutputStream For writing filtered byte streams, which may transform the basic source of data along the way and provide additional functionalities. ObjectOutputStream Used for object serialization. Serializes object and primitve data to OuputStream. DataOutputStream A subclass of FilterOutputStream that lets an application write Java primitive data to underlying output stream in machine-independent way. PrintStream A subclass of FilteOutputStream that provides capability for printing representations of various data values conveniently.
  • 42. 19 The Reader Class: Methods public int read() throws IOException c mot ký t public int read(char[] cbuf) throws IOException c nh
  • 43. ng ký t và lưu chúng vào m ng cbuf public abstract int read(char[] cbuf, int off, int len) throws IOException c len ký t và lưu chúng vào tron m ng cbuf, bat âu ti v trí off ca m ng public abstract void close() throws IOException óng luông. Gi nh
  • 44. ng phương thc Reader khác ca sau khi gi close se gây ra loi IOException public void mark(int readAheadLimit) throws IOException ánh dâu v trí hien hành ca stream. Sau khi ánh dâu, gi reset() e th at li v trí luông ti iem này. Không ph i tât c character-input êu ho tr thao tác này public boolean markSupported() Ch ra luông có ho tr thao tác này hay không. Mac nh là không ho tr. public void reset() throws IOException at li v trí luông ti v trí ánh dâu lân cuôi
  • 45. 20 Node Reader Classes FileReader Cho viec c t file CharArrayReader Thc thi mot vùng em ký t có the ưc c StringReader Cho viec c t nguôn string PipedReader Dùng theo cap (tương ng vi PipedWriter) bang 2 luông mà chúng có the liên lc vi nhau.Mot trong nh
  • 46. ng cái luông c các ký t.
  • 47. 21 Filter Reader Classes BufferedReader Allows buffering of characters in order to provide for efficient reading of characters, arrays, and lines FilterReader For reading filtered character streams InputStreamReader Converts read bytes to characters LineNumberReader A subclass of BufferedReader class that able to keep track of line numbers. PushbackReader A subclass of the FilterReader class that allows character to pushed back or unread into the stream.
  • 48. 22 The Writer Class: Methods public void write(int c) throws IOException Ghi mot ký t ơn ưc the hien bang sô nguyên. Ví d: ‘A’ là ưc ghi la write(65) public void write(char[] cbuf) throws IOException Ghi noi dung ca m ng ký t cbuf xuông luông public abstract void write(char[] cbuf, int off, int len) throws IOException Ghi mot m ng ký t cbuf vi chiêu dài là len, bat âu là v trí off public void write(String str) throws IOException Ghi mot chuoi str public void write(String str, int off, int len) throws IOException Ghi mot chuoi str vi chiêu dài là len, bat âu t v trí off public abstract void flush() throws IOException ay d
  • 49. lieu xuông ích ên. public abstract void close() throws IOException óng luông.
  • 50. 23 Node Writer Classes FileWriter For writing to character to file CharArrayWriter Implements a character buffer that can be written to StringWriter For writing to a string source PipedWriter Used in pairs(with corresponding with PipedReader) by two threads that want to communicate. One of these threads writes characters to this stream.
  • 51. 24 Filter Writer Classes BufferedWriter Allows buffering of characters in order to provide for the efficient writing of characters, arrays, and lines. FilterWriter For writing filtered character streams. OutputStreamWriter Encodes characters written to it into bytes. PrintWriter Prints formatted representations of objects to a text-output stream.
  • 52. 25 iêu khien luông nhap xuât(I/O) To ôi tưng luông và liên kêt nó vi d
  • 53. lieu nguôn(data-destination) ưa ra ôi tưng luông vi chc nang mong muôn thông qua chuoi luông (Give the stream object the desired functionality through stream chaining) óng luông
  • 54. 26 Byte Stream Chương trình s dng luông byte e thc hien nhap xuât nh
  • 55. ng byte 8-bit Tât c cá lp luông byte ưc kê tha t InputStream và OutputStream Có nhiêu lp luông byte FileInputStream và FileOutputStream Chúng ưc s dng trong cùng mot cách; chúng khác nhau ch yêu là cách thc chúng ưc kh#i to.
  • 56. 27 Khi nào không s
  • 57. d ng Byte Stream Byte Stream the hien mot loi d
  • 58. lieu nhap xuât mc thâp do ó chúng ta nên tránh: Nêu d
  • 60. ng ký t, phương pháp tôt nhât là s dng character streams Có nh
  • 63. lieu phc tp Byte Stream ch nên s dng cho hâu hêt nh
  • 64. ng nhap xuât nguyên thy Tât c các stream khác êu ưc da trên byte stream
  • 65. 28 Example: FileInputStream FileOutputStream import java.io.*; public class CopyBytes { public static void main(String[] args) throws IOException { FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream(“d:/src.txt); out = new FileOutputStream(“d:/dst.txt); int c; while ((c = in.read()) != -1) { out.write(c); } } finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } } }
  • 66. 29 Simple Byte Stream input and output InputStream H e l l o Y o u b = read() write(b) Y H e l l o Y OutputStream
  • 67. 30 Character Stream Java platform lưu tr
  • 68. nh
  • 69. ng giá tr ký t theo dng Unicode Tât c các lp character stream ưc kê tha t Reader và Writer Có các lp character stream : FileReader và FileWriter.
  • 70. 31 Example: FileReader FileWriter public class CopyCharacters { public static void main(String[] args) throws IOException { FileReader inputStream = null; FileWriter outputStream = null; try { inputStream = new FileReader(“d:/fileIn.txt); outputStream = new FileWriter(“d:/fileOut.txt); int c; while ((c = inputStream.read()) != -1) { outputStream.write(c);} } finally { if (inputStream != null) { inputStream.close(); } if (outputStream != null) { outputStream.close(); } } } }
  • 71. 32 Character Stream và Byte Stream Character stream thưng là wrappers“ cho byte stream Character stream s dng byte stream thc hien nhap xuât vat lý, trong khi character stream x lý chuyen oi gi
  • 72. a character và byte Chang hn FileReader dùng như FileInputStream, trong khi FileWriter dùng như FileOutputStream
  • 73. 33 Buffered Streams Mot I/O không có bo em có nghia là moi yêu câu c hoac ghi ưc x lý trc tiêp b#i OS iêu này làm chương trình kém hieu qu , vì moi yêu câu thưng ph i truy xuât ia, hot ong mng, hoac mot và thao tác khá mà nó tương ôi tôn thi gian. e gi m công viec loi này, Java platform thc thi luông I/O có bo em Buffered input stream c d
  • 74. lieu t vùng nh như là bo em; API input ưc gi ch khi bo em rong. Tương t, buffered output stream ghi d
  • 75. lieu xuông bo em, và API output ch ưc gi khi buffer ây.
  • 76. 34 To Buffered Stream? Mot chương trình có the chuyen mot stream không có bo em thành stream có bo em bang cách s dng v) bao. Mot unbuffered stream object ưc chuyen qua hàm dng cho mot lp stream có bo em Ví d: inputStream = new BufferedReader(new FileReader(characterinput.txt)); outputStream = new BufferedWriter(new FileWriter(characteroutput.txt));
  • 77. 35 Buffered Stream Classes BufferedInputStream và BufferedOutputStream to ra byte stream có bo em BufferedReader và BufferedWriter to ra character stream có bo em
  • 78. 36 Standard Streams on Java Platform Có 3 standard stream Input: System.in Output: System.out Error: System.err Nh
  • 79. ng ôi tưng này ưc nh nghia t ong và không cân thiêt ưc m#. System.out and System.err ưc nh nghia như là nh
  • 81. 37 Data Streams Data stream ho tr nhap xuât nh phân ca các loi d
  • 82. lieu nguyên thu* (boolean, char, byte, short, int, long, float, and double) cung như là String Tât c data stream thc thi c DataInput cung nh DataOutput interface DataInputStream and DataOutputStream thc thi nh
  • 85. 38 DataOutputStream DataOutputStream có the ch ưc to như là mo v) bc cho ôi tưng byte stream out = new DataOutputStream( new BufferedOutputStream( new FileOutputStream(dataFile))); for (int i = 0; i prices.length; i ++) { out.writeDouble(prices[i]); out.writeInt(units[i]); out.writeUTF(descs[i]); }
  • 86. 39 DataInputStream Giông như DataOutputStream, DataInputStream ph i ưc xây dng như là mot v) bc cho ôi tưng byte stream iêu kien End-of-file ưc dò b#i biet le EOFException, thay vì kiem tra e tr vê giá tr hêt file. in = new DataInputStream(new BufferedInputStream( new FileInputStream(dataFile))); try{ double price = in.readDouble(); int unit = in.readInt(); String desc = in.readUTF(); } catch (EOFException e){ }
  • 87. 40 Object Streams Object streams support I/O of objects Like Data streams support I/O of primitive data types The object has to be Serializable type The object stream classes are ObjectInputStream and ObjectOutputStream These classes implement ObjectInput and ObjectOutput, which are subinterfaces of DataInput and DataOutput An object stream can contain a mixture of primitive and object values
  • 88. 41 Input and Output of Complex Object The writeObject and readObject methods are simple to use, but they contain some very sophisticated object management logic This isn't important for a class like Calendar, which just encapsulates primitive values. But many objects contain references to other objects. If readObject is to reconstitute an object from a stream, it has to be able to reconstitute all of the objects the original object referred to. These additional objects might have their own references, and so on.
  • 89. 42 WriteObject The writeObject traverses the entire web of object references and writes all objects in that web onto the stream A single invocation of writeObject can cause a large number of objects to be written to the stream.
  • 90. 43 I/O of multiple referred-to objects Object a contains references to objects b and c, while b contains references to d and e
  • 91. 44 I/O of multiple referred-to objects Invoking writeObject(a) writes not just a, but all the objects necessary to reconstitute a, so the other four objects in this web are written also When a is read back by readObject, the other four objects are read back as well, and all the original object references are preserved.
  • 92. 45 Always Close Streams Closing a stream when it's no longer needed is very important — so important that your program should use a finally block to guarantee that both streams will be closed even if an error occurs This practice helps avoid serious resource leaks.
  • 93. 46 The File Class Not a stream class Important since stream classes manipulate File objects Abstract representation of actual files and directory pathname
  • 94. 47 The File Class: Constructor Methods public File(String pathname) public String getName() public boolean exists() public long length() public long lastModified() public boolean canRead() public boolean canWrite() public boolean isFile() public boolean isDirectory() public String[] list() public boolean mkdir() public boolean delete()
  • 95. 48 The File Class: Example import java.io.*; public class FileInfoClass { public static void main(String args[]) { String fileName = args[0]; File fn = new File(fileName); System.out.println(Name: + fn.getName()); if (!fn.exists()) { System.out.println(fileName + does not exists.); /* Create a temporary directory instead. */ System.out.println(Creating temp directory...); fileName = temp; fn = new File(fileName); fn.mkdir(); System.out.println(fileName + (fn.exists()? exists: does not exist)); System.out.println(Deleting temp directory...); fn.delete(); }
  • 96. 49 The File Class: Example System.out.println(fileName + is a + (fn.isFile()? file. :directory.)); if (fn.isDirectory()) { String content[] = fn.list(); System.out.println(The content of this directory:); for (int i = 0; i content.length; i++) System.out.println(content[i]); } if (!fn.canRead()) { System.out.println(fileName + is not readable.); return; } System.out.println(fileName + is + fn.length() + bytes long.); System.out.println(fileName + is + fn.lastModified() + bytes long.); if (!fn.canWrite()) { System.out.println(fileName + is not writable.); } } }