عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 25-12-2013, 03:37 AM   #2

Martian

جامعي

 
تاريخ التسجيل: Dec 2013
كلية: أخرى
التخصص: Computer Science/Psy
نوع الدراسة: إنتظام
المستوى: الثالث
البلد: امريكا
الجنس: ذكر
المشاركات: 1
Talking رد: حل واجب في cs201 ارجو المساعدة

السلام عليكم,
هذا كود اول جزء من السؤال الأول
كود:
import java.io.*;
import java.util.*;
public class test11
{

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException
	{
		Scanner input = new Scanner(System.in);
		PrintStream out = System.out;
		
		out.println("Enter a name for your .txt file: (include the file extension)");
		String filename = input.nextLine();
		File f = new File(filename);
		FileOutputStream fos = new FileOutputStream(f);
		PrintStream p = new PrintStream(fos);
		boolean isExist = f.exists();
		if(isExist == true){
			out.println("File has been created!!");
		}else if(isExist == false){
			out.println("File is not created");
		}
		
		System.out.println("Enter data to be written in txt file:");
		String s;
		for(s = input.nextLine(); !s.isEmpty(); s = input.nextLine())
		{
			p.println(s);
		}
		p.close();
		
	}

}
علمني اذا هذا اللي تبيه او لا

 

Martian غير متواجد حالياً   رد مع اقتباس