Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CheckTheWord {
- public static String[] checkTheWord(String s, char zn, char zn2) {
- int l = 0;
- for (int i = 0; i < s.length(); i++) {
- if (s.charAt(i) == zn || s.charAt(i) == zn2) {
- l++;
- }
- }
- String[] tStr = new String[l + 1];
- for (int i = 0; i < tStr.length; tStr[i++] = "") ;
- l = 0;
- for (int i = 0; i < s.length(); i++) {
- if (s.charAt(i) == zn || s.charAt(i) == zn2) {
- l++;
- } else {
- tStr[l] += s.charAt(i);
- }
- }
- return tStr;
- }
- public boolean isThereAvulgarWord(String lan) {
- // String lan = "Ala ma kota Kot_ma_Alę";
- String b[] = {"chuj", "choj","chój","huj", "hój", "kurwa",
- "kórwa","korwa","zjebanie","chujowo","chójowo","chojowo"};
- boolean wynik = false;
- String[] tmpTStr2 = checkTheWord(lan, ' ', ',');
- for (int i = 0; i < tmpTStr2.length; i++) {
- for (int j = 0; j < b.length; j++) {
- if (tmpTStr2[i].equals(b[j])) {
- return wynik = true;
- }
- }
- }
- return wynik;
- }
- }
- -------------------------------------------------------------------------------------------------------------------
- @PostMapping("/save")
- public String save(Comment comment) {
- String text = comment.getCommentUser();
- CheckTheWord checkTheWord = new CheckTheWord();
- checkTheWord.isThereAvulgarWord(text);
- if(checkTheWord.isThereAvulgarWord(text)== true){
- return "redirect:/";
- }else
- commentRepository.save(comment);
- return "redirect:/allComment";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement