Universitet jizzax filiali


Javobi: 9-amaliy mashg’ulot


Download 179.79 Kb.
bet3/4
Sana30.04.2023
Hajmi179.79 Kb.
#1412559
1   2   3   4
Bog'liq
Structura 3 modul

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());
} else {
System.out.println("Fayl mavjud emas.");
}
}
}
CSV fayliga yozish:
import java.io.FileWriter;
import java.io.IOException;
class WriteToFile {
public static void main(String[] args) {

try {
FileWriter fwrite = new FileWriter("T:9_amaliy.csv");


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:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling