Java-dagi FileOutputStream sinfi


Misol: Java FileOutputStream yordamida mag'lubiyatga oid ma'lumotlarni yozing


Download 18.53 Kb.
bet3/3
Sana19.02.2023
Hajmi18.53 Kb.
#1214442
1   2   3
Bog'liq
9-Amaliy mashg\'ulot

Misol: Java FileOutputStream yordamida mag'lubiyatga oid ma'lumotlarni yozing


Shuningdek, biz qatorni baytlar qatoriga aylantirishimiz va ma'lumotlarni ko'rsatilgan joyga yozishimiz mumkin Fayl Java FileOutputStream sinfidan foydalanish. Quyida satrni faylga yozish misoli keltirilgan.

import java.io.FileNotFoundException;


import java.io.FileOutputStream;
import java.io.IOException;

public class WriteFile {


public static void main(String[] args) throws FileNotFoundException {


FileOutputStream fo = new FileOutputStream("OutputFile.txt");
String text = "Welcome to Java programming";
try {
byte[] b = text.getBytes();
fo.write(b);
fo.close();
System.out.println("String data successfully written to the file");
} catch (IOException e) {
e.printStackTrace();
}

}


}
String data successfully written to the file
Download 18.53 Kb.

Do'stlaringiz bilan baham:
1   2   3




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