I have got given a homework:
FileDescription program requests (as shown) and reads three lines of text. It then processes the data.
For each line the first string (containing no spaces) on the line is a file name – followed by a file description.
If the file name has the suffix (ends with) .txt then the name and description is printed out e.g
XXXX.txt: Stuff about the file
where XXXX.txt is the file name. Otherwise output is like this:
FFFF: Not a text file
where FFFF is the filename.
Example:
Program Name : FileDescription.java
(Example) Input/Output:
Please enter file name and description:
list.txt This my shopping list
list.txt: This my shopping list
Please enter file name and description:
batty.exe A compiled, executable file
batty.exe: Not a text file
Please enter file name and description:
Blip.class A Java byte file
Blip.class: Not a text file
Questions:
1. How can I split the user input on each line into two strings so I manipulate them when I don't know how long the first string is?