with open("guest.txt", "w") as file:
file.write(input())
package vika;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
System.out.println("Введите Ваше имя:");
Scanner scanner = new Scanner (System.in);
String name = scanner.nextLine();
// java
try (BufferedWriter writer = new BufferedWriter(new FileWriter("guest.txt", true)))
{
writer.write(name);
writer.newLine();
}
catch ( IOException e )
System.out.println(e.getMessage());
with open("guest.txt", "w") as file:
file.write(input())
package vika;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
System.out.println("Введите Ваше имя:");
Scanner scanner = new Scanner (System.in);
String name = scanner.nextLine();
// java
try (BufferedWriter writer = new BufferedWriter(new FileWriter("guest.txt", true)))
{
writer.write(name);
writer.newLine();
}
catch ( IOException e )
{
System.out.println(e.getMessage());
}
}
}