Universitet jizzax filiali


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

CSV faylidan o’qish:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

class ReadFromFile {


public static void main(String[] args) {
try {
File f1 = new File("T:9_amaliy.csv");
Scanner dataReader = new Scanner(f1);
while (dataReader.hasNextLine()) {
String fileData = dataReader.nextLine();
System.out.println(fileData);
}
dataReader.close();
} catch (FileNotFoundException exception) {
System.out.println("Kutilmagan xatolik yuz berdi!");
exception.printStackTrace();
}
}
}

CSV faylini o’chirish:
import java.io.File;
class DeleteFile {
public static void main(String[] args) {
File f0 = new File("T:9_amaliy.csv");
if (f0.delete()) {
System.out.println(f0.getName()+ " fayl muvaffaqiyatli o'chirildi.");
} else {
System.out.println("Faylni o'chirishda kutilmagan xatolik topildi.");
}
}
}
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