السلام عليكم,
هذا كود اول جزء من السؤال الأول
كود:
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();
}
}
علمني اذا هذا اللي تبيه او لا