SlideShare a Scribd company logo
Modul kelas Java programming.
© FGroupIndonesia.com
 Pengertian IO
 Object File
 Praktek Fungsi File
 Praktek IO
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
 I berarti Input
 O berarti Output
 Java IO berarti setiap fungsi yg erat kaitannya
dengan Input & Output (baca & tulis)
terhadap suatu file lain.
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
 Dalam java suatu Object dari File mampu
digunakan untuk melakukan beberapa
operasi umum seperti :
 Memeriksa jenis File / Dir.
 Mendapatkan alamat Path
 Mendapatkan nama File / Dir
 Dsb...
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
 Pembuatan File (baru)
 Gunakan import java.io.File;
File pembuat = new File("file.txt");
try {
pembuat.createNewFile();
} catch (Exception ex) {
System.err.println("Terjadi kesalahan saat writing file!");
}
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
Buka lokasi Project Netbeans, apa bedanya?
 Pembuatan Folder (baru)
 Gunakan import java.io.File;
File pembuat = new File(“data");
try {
pembuat.mkdir();
} catch (Exception ex) {
System.err.println("Terjadi kesalahan saat writing folder!");
}
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
Buka lokasi Project Netbeans, apa bedanya?
 Fungsi lain Object File
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
Method Fungsi ReturnValue
.delete() Menghapus
file/folder
boolean
.isFile() /
isDirectory()
Mengecek
keberadaan file /
folder
boolean
.getAbsolutePath() Memberikan lokasi
lengkap
String
.getName() Memberikan nama
file / folder
String
 Fungsi lain Object File
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
Method Fungsi ReturnValue
.listFiles() Memberikan
nama-nama file /
folder
File [] (array)
.listFiles(Filter) Memberikan nama
file/folder
berdasarkan filter
khusus
File [] (array)
 Output > Digunakan untuk mengirim /
menulis sesuatu terhadap suatu file.
File objek = new File("file.txt");
FileWriter penulis = new FileWriter(objek);
penulis.write("Konten-1");
penulis.write("n");
penulis.write("Konten-2");
penulis.close();
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
Buka lokasi Project Netbeans, apa yg terjadi?
 Fungsi lain yg serupa:
File objek = new File("file-setting.txt");
BufferedWriter penulis = new BufferedWriter(new FileWriter(objek));
penulis.write("Konten-1");
penulis.newLine();
penulis.write("Konten-2");
penulis.close();
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
Buka lokasi Project Netbeans, apa yg terjadi?
 Cobalah untuk:
 Membuat satu folder [users]
 Memiliki sub file :
▪ [user1.txt] : berisi : [username, password]
▪ [user2.txt] : berisi : [username, password]
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
Gunakan Code sebelumnya untuk pembuatan Folder
& penulisan File!
 Input > Digunakan untuk menerima / membaca
sesuatu dari suatu file.
File objek = new File("file.txt");
FileReader pembaca = new FileReader(objek);
char terbaca [] = new char[20];
pembaca.read(terbaca);
for(char huruf: terbaca){
System.out.print(huruf);
}
pembaca.close();
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
 Fungsi lain yang serupa:
File objek = new File("file.txt");
BufferedReader pembaca = new BufferedReader(new
FileReader(objek));
String terbaca = null;
while((terbaca = pembaca.readLine())!= null){
System.out.println(terbaca);
}
pembaca.close();
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
 Cobalah untuk:
 Membaca kembali file user1.txt, dan user2.txt tadi
 Munculkan ke GUI (textfield).
 Lanjutkan pula pada
Proses penulisan,
Sehingga saving file
Berhasil.
---------------------------------------------------------------------------
Kursus Online / Offline di © FGroupIndonesia.com
FGroupIndonesia.com
Jl. Parahyangan no.18, Komp. Panghegar Permai I
Ujung Berung, Bandung 40614
(022) 92800446 / 95244964
BBM. 7DF95683 / 7CD59179
WA. 085795569337 / 085721261437

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Modul Kelas Programming : Java IO (Input & Output)

  • 1. Modul kelas Java programming. © FGroupIndonesia.com
  • 2.  Pengertian IO  Object File  Praktek Fungsi File  Praktek IO --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com
  • 3.  I berarti Input  O berarti Output  Java IO berarti setiap fungsi yg erat kaitannya dengan Input & Output (baca & tulis) terhadap suatu file lain. --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com
  • 4.  Dalam java suatu Object dari File mampu digunakan untuk melakukan beberapa operasi umum seperti :  Memeriksa jenis File / Dir.  Mendapatkan alamat Path  Mendapatkan nama File / Dir  Dsb... --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com
  • 5.  Pembuatan File (baru)  Gunakan import java.io.File; File pembuat = new File("file.txt"); try { pembuat.createNewFile(); } catch (Exception ex) { System.err.println("Terjadi kesalahan saat writing file!"); } --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com Buka lokasi Project Netbeans, apa bedanya?
  • 6.  Pembuatan Folder (baru)  Gunakan import java.io.File; File pembuat = new File(“data"); try { pembuat.mkdir(); } catch (Exception ex) { System.err.println("Terjadi kesalahan saat writing folder!"); } --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com Buka lokasi Project Netbeans, apa bedanya?
  • 7.  Fungsi lain Object File --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com Method Fungsi ReturnValue .delete() Menghapus file/folder boolean .isFile() / isDirectory() Mengecek keberadaan file / folder boolean .getAbsolutePath() Memberikan lokasi lengkap String .getName() Memberikan nama file / folder String
  • 8.  Fungsi lain Object File --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com Method Fungsi ReturnValue .listFiles() Memberikan nama-nama file / folder File [] (array) .listFiles(Filter) Memberikan nama file/folder berdasarkan filter khusus File [] (array)
  • 9.  Output > Digunakan untuk mengirim / menulis sesuatu terhadap suatu file. File objek = new File("file.txt"); FileWriter penulis = new FileWriter(objek); penulis.write("Konten-1"); penulis.write("n"); penulis.write("Konten-2"); penulis.close(); --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com Buka lokasi Project Netbeans, apa yg terjadi?
  • 10.  Fungsi lain yg serupa: File objek = new File("file-setting.txt"); BufferedWriter penulis = new BufferedWriter(new FileWriter(objek)); penulis.write("Konten-1"); penulis.newLine(); penulis.write("Konten-2"); penulis.close(); --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com Buka lokasi Project Netbeans, apa yg terjadi?
  • 11.  Cobalah untuk:  Membuat satu folder [users]  Memiliki sub file : ▪ [user1.txt] : berisi : [username, password] ▪ [user2.txt] : berisi : [username, password] --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com Gunakan Code sebelumnya untuk pembuatan Folder & penulisan File!
  • 12.  Input > Digunakan untuk menerima / membaca sesuatu dari suatu file. File objek = new File("file.txt"); FileReader pembaca = new FileReader(objek); char terbaca [] = new char[20]; pembaca.read(terbaca); for(char huruf: terbaca){ System.out.print(huruf); } pembaca.close(); --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com
  • 13.  Fungsi lain yang serupa: File objek = new File("file.txt"); BufferedReader pembaca = new BufferedReader(new FileReader(objek)); String terbaca = null; while((terbaca = pembaca.readLine())!= null){ System.out.println(terbaca); } pembaca.close(); --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com
  • 14.  Cobalah untuk:  Membaca kembali file user1.txt, dan user2.txt tadi  Munculkan ke GUI (textfield).  Lanjutkan pula pada Proses penulisan, Sehingga saving file Berhasil. --------------------------------------------------------------------------- Kursus Online / Offline di © FGroupIndonesia.com
  • 15. FGroupIndonesia.com Jl. Parahyangan no.18, Komp. Panghegar Permai I Ujung Berung, Bandung 40614 (022) 92800446 / 95244964 BBM. 7DF95683 / 7CD59179 WA. 085795569337 / 085721261437