الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

سؤال بسيط

بدأه هنوالحلوه في 24 أكتوبر 2010 · 7 رد · 555 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

. a. Develop a class with 2 methods: main() and writeText

The name of the class should be your first name (for example: public class Ali).

The writeText()method includes statements to write some text to the file "C:\myFile.txt". The writeText()method is called from within the main() method.

IOException in writeText()is not handled in any try–catch statement within the method.

Instead, this exceptionis handled in the main()method by a try-catch statement.

b. Using the class in (a) above as an example, discuss what happens if the code in writeText()method throws an IOException. Justify your answer.

c. What if no handler (i.e. try-catch statements) exists at any level for the above exception

#2

اختي وودي أساعدج لكن مااعرف الإجابه !!

^^

حطي أي كود عشااان مايصكرون موضوعج

#3

تمام يا *en* ..... .. مشاء الله .... :D

حطي يا "هنو" محاولاتك ... + السؤال في العربيه .. لكي لا يصنكرو موضوعك :D

#4

يعني ليش عندكم بيسكروا الموضوع بسرعه والله لو أني فاهمه سؤال كنت حليت الأكواد

#5
اقتباس
لكي لا يصنكرو موضوعك

لا رايق اوى انهاردة.........هههههههههههههه

−1
00020309t.gif

1958_1963.gif
#6

اختي مو آنا اللي أحط القوانين بس على الأقل لو كود أي شي مو شرط صح ترى يمشي الحال ويعدونها لج

=)

#7

أختي الكريمة

السؤال الي مكتوب لو قمت بالبحث داخل المواضيع المثبته لو حصلتي على ضالتك

وبصراحة السؤال يمكنك حله لانه السؤال مجر د مبادئ في ال I/O Streem

تحياتي

وَعَبْدٌ قَدْ يَنامُ عَلَى حَرِيرٍ ××× وَذُو نَسَبٍ مَفَارِشُهُ التُّرَابُ

#8

حضرتك المفروض تجاوبى على الاسئله بعد ما تشوفى الكود

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Mahmoud Kelany
 */
public class TestWriter {

	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
    	System.out.println("Write your text to be save into a file : ");
    	String txt = input.next();
    	try {
        	writeText(txt);
    	} catch (IOException ex) {
        	Logger.getLogger(TestWriter.class.getName()).log(Level.SEVERE, null, ex);
    	}
	}

	public static void writeText(String txt) throws IOException {
    	FileWriter fileWriter = new FileWriter("c:\\myFile.txt");
    	fileWriter.write(txt);
    	fileWriter.close();
	}
}

ان شاء الله تتمكنى من ذلك

بالتوفيق

Software Developer
Mahmoudkelany.com


 

مواضيع مشابهة