Good day to all.. I am a beginner in java. I have a problem, I don't know how to convert string into an array which reads 60 characters.. supposedly, this is my code..
import java.io.*;
import java.util.*;
public class Strinpunct{
public static void main (String [] args) throws IOException {
BufferedReader br=new BufferedReader (new InputStreamReader (System.in));
String str;
System.out.println("Enter an input: ");
str=br.readLine();
String listOfDelimiters = ".,!?1234567890()'-";
StringTokenizer token = new StringTokenizer(str,listOfDelimiters);
while(token.hasMoreTokens())
System.out.print(token.nextToken());
}
}
In this code, I have to separate words from punctuation marks so I used delimiters. My problem now is the length of the string. It must contain 60 characters. For example, I will input this:
A common problem when processing incoming text is to isolate
the words in the text. This is made more difficult by the
punctuation; words have commas, "quote marks",
(even brackets) next to them, or hyphens
in the middle of the word. This punctuation doesn't
count as letters when the words have to be looked up in a
# dictionary by the 12345 "**&! program.
#
the output will be..
A common problem when processing incoming text is to isolate
the words in the text This is made more difficult by the
punctuation words have commas quote marks
even brackets next to them or
hyphens
in the middle of the word This punctuation doesnt
count as letters when the words have to be looked up in a
dictionary by the program
In the program I had created, the output that will come out will just be the words "A common problem when processing incoming text is to isolate" the next words won't come out. Please teach me how to convert string into arrays of string consist of 60 characters in each line. Or Any help would be great. thank you soo much..