Universitet jizzax filiali
Javobi: 9-amaliy mashg’ulot
Download 179.79 Kb.
|
Structura 3 modul
- Bu sahifa navigatsiya:
- CSV faylini yaratish
- CSV faylni tekshirish
- CSV fayliga yozish
Javobi:
9-amaliy mashg’ulot. Graflar tushunchasi Sizning vazifangiz Linked list, dictionary masalalarini yechish hisoblanadi. 2. CSV formatida bo’lgan so’z uning ta’riflari lug’ati berilgan. Sizning vazifangiz ushbu lug’atni Java dasturlash tilida fayl sifatida chaqirib olish va ular ustida bajariladigan turli amallar hisoblanadi.( Izox: Csv faylidagi so'z ta'riflarini lug'atda o'qish va saqlash uchun Java dasturini amalga oshirish Java-da I/u faylini va lug'at manipulyatsiyasini o'rganishning amaliy usuli hisoblanadi.) CSV faylini yaratish: import java.io.File; import java.io.IOException; class CreateFile { public static void main(String args[]) { try { File f0 = new File("T:9_amaliy.csv"); if (f0.createNewFile()) { System.out.println("Fayl " + f0.getName() + " muvaffaqiyatli yaratildi."); } else { System.out.println("Fayl allaqachon katalogda mavjud."); } } catch (IOException exception) { System.out.println("Kutilmagan xatolik yuz berdi."); exception.printStackTrace(); } } } CSV faylni tekshirish: import java.io.File; class FileInfo { public static void main(String[] args) { File f0 = new File("T:9_amaliy.csv"); if (f0.exists()) { System.out.println("Fayl nomi: " + f0.getName()); System.out.println("Faylning mutlaq yo'li: " + f0.getAbsolutePath()); System.out.println("Fayl yozish mumkinmi: " + f0.canWrite()); System.out.println("Fayl o'qilishi mumkinmi: " + f0.canRead()); System.out.println("Faylning baytdagi hajmi: " + f0.length());
try {
fwrite.write("Apricot - abricos \n" + "Banana - banan \n" + "Blackberry - ejevika\n" + "Blueberry - chernika\n" + "Cherry - vijnaya\n" + "Cranberry -klyukva\n" + "Currant - smorodina\n" + "Fig - injir\n" + "Grape - vinograd\n" + "Kiwi - kivi\n"); fwrite.close(); System.out.println("Kontent faylga muvaffaqiyatli yozildi."); } catch (IOException e) { System.out.println("Kutilmagan xatolik yuz berdi"); e.printStackTrace(); } } } Download 179.79 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling