Когда я пытаюсь запустить этот фрагмент,
import java.io.*;
import java.util.Scanner;
import static java.lang.System.*;
class CSWrite1
{
public static void main(String[] args) throws IOException
{
Scanner input = new Scanner(in);
out.print("Enter the filename\t>");
String file = input.next();
out.println("Enter the text");
String text = input.next(); // IN:"Hello, How are you" --> "Hello,
try(FileWriter fw = new FileWriter(file))
{ fw.write(text); }
}
}
при вводе текста как «Привет, как дела?» Файл записывается только с «Привет,». Оставшийся текст послепервый пробел не записывается в файл.