-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseqTextReader.java
More file actions
55 lines (44 loc) · 1.68 KB
/
seqTextReader.java
File metadata and controls
55 lines (44 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.util.*;
import java.lang.String;
public class seqTextReader
{
public static void clrConsole() {
System.out.print("\033[H\033[2J");
System.out.flush();
}
public static void main(String[] args)
{
double delay = 0.035; // 0.035 is default delay factor (seconds). line 44 used
ArrayList<String> streamText = new ArrayList<String>();
Scanner input = new Scanner(System.in);
System.out.println("Please provide the string to process.");
System.out.print("> ");
String strSource = input.nextLine();
clrConsole();
strSource = strSource.trim();
while (strSource.contains(" ")) {
for (int i = 0; i < strSource.length(); i++) {
if ((strSource.substring(i, i+1)).equals(" ")) {
streamText.add((strSource.substring(0,i)).trim());
strSource = strSource.substring(i+1,strSource.length());
i = 0;
}
}
}
if (!strSource.isEmpty()) {
streamText.add(strSource);
}
clrConsole();
for (int i = 0; i < streamText.size(); i++) {
System.out.print(streamText.get(i));
System.out.print(" ");
int wordDelay = (int) Math.round((0.05 + (streamText.get(i).length() * delay))*1000);
try {
Thread.sleep(wordDelay);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.err.println("Thread was interrupted: " + e.getMessage());
}
}
}
}