Resources:
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
الطبقة العامة WriteFileExample {
الفراغ الثابت العام الرئيسي (سلسلة [] args) {
FileOutputStream fop = null ؛
ملف ملف ؛
Content String = "المحتوى المضاف" ؛
try {
file = new File ("test.txt") ؛
fop = جديد FileOutputStream (ملف);
// إنشاء الملف إذا لم يكن موجودا
إذا (!file.exists()) {
file.createNewFile();
}
// تحويل إلى بيانات ثنائية
بايت [] contentEnBytes = content.getBytes();
fop.write (محتوى EnBytes) ؛
fop.flush ();
fop.close ();
System.out.println ("اكتمل التحرير!") ؛
} catch (IOException e) {
e.printStackTrace();
} أخيرا {
جرب {
إذا كان (fop!= null) {
fop.close();
}
} الصيد (IOException e) {
e.printStackTrace ();
}
}
}
}
Please disable your ad blocker and refresh the window to use this website.