-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f999e5e
commit c697f7d
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package Format; | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class Format { | ||
final int MAX_LETTER_NUMBER; | ||
final int A_SMALL_CODE; | ||
final int A_BIG_CODE; | ||
final int MAX_LETTER_NUMBER_IN_LINE; | ||
final int MAX_WORD_NUMBER; | ||
final char DOT, COMMA, EXCLAMATION, QUESTION, DASH, COLON, QUOTES, SEMICOLON; | ||
|
||
String[] Text; | ||
int wordNum; | ||
|
||
public Format() { | ||
MAX_LETTER_NUMBER = 26; | ||
A_SMALL_CODE = 97; | ||
A_BIG_CODE = 65; | ||
MAX_LETTER_NUMBER_IN_LINE = 20; | ||
MAX_WORD_NUMBER = 200; | ||
DOT = '.'; | ||
COMMA = ','; | ||
QUESTION = '?'; | ||
DASH = '-'; | ||
COLON = ':'; | ||
QUOTES = '"'; | ||
EXCLAMATION = '!'; | ||
SEMICOLON = ';'; | ||
Text = new String[MAX_WORD_NUMBER]; | ||
wordNum = 0; | ||
} | ||
|
||
public boolean compareToPunct(char c) { | ||
if (c == DOT || c == COMMA || c == QUESTION || c == DASH || c == COLON || c == QUOTES || c == EXCLAMATION || c == SEMICOLON) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public void loadText(String fileName) throws IOException { | ||
BufferedReader reader = new BufferedReader(new FileReader(fileName)); | ||
String s; | ||
s = reader.readLine(); | ||
StringTokenizer st = new StringTokenizer(s); | ||
wordNum = 0; | ||
while (st.hasMoreTokens()) { | ||
Text[wordNum] = st.nextToken(); | ||
wordNum++; | ||
} | ||
} | ||
|
||
public void print() { | ||
for (int i = 0; i < wordNum; i++) | ||
System.out.println(Text[i]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello! My name is Kate. I'm a second year student of the Belarusian State University the Faculty of Applied Mathematics and Computer Science. I really engoy studying here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Format.*; | ||
|
||
import java.io.IOException; | ||
|
||
public class MyMain { | ||
public static void main(String[] args) throws IOException{ | ||
Format f = new Format(); | ||
f.loadText("C:\\Users\\Kate\\IdeaProjects\\program5\\src\\Format\\myText.txt"); | ||
f.print(); | ||
} | ||
} |