diff --git a/pom.xml b/pom.xml index 42b41de..9e75dd9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ficbook.net_Parser ficbook.net_Parser - 2.1.0-SNAPSHOT + 2.1.7-SNAPSHOT UTF-8 diff --git a/src/main/java/Main.java b/src/main/java/Main.java index a26fd1d..410cac6 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -194,33 +194,34 @@ public void parsing(String textFromJText) { is = url.openStream(); brs = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); FileWriter writerFile = new FileWriter(pathForHTML, StandardCharsets.UTF_8); - //Сохраняем просто в файл site.html //форматируем текст while ((lines = brs.readLine()) != null) { - writerFile.write(lines - .replaceAll(" ", "") - .trim() - .replaceAll("", "") - .replaceAll("", "") - .replaceAll("", "") - .replaceAll("", "") - .replaceAll("

", "") - .replaceAll("

", "") - .replaceAll("
", "") - .replaceAll("", "") - .replaceAll("", "") - .replaceAll("
", "") - .replaceAll("
", "") - .replaceAll("

", "") - .replaceAll("

", "") - + System.getProperty("line.separator")); + writerFile.write(lines + .replaceAll(" ", "") + .trim() + .replaceAll("", "") + .replaceAll("

", "") + .replaceAll("
", "") + .replaceAll("", "") + .replaceAll("

", "") + .replaceAll("

", "") + .replaceAll("
", "") + .replaceAll("", "") + .replaceAll("", "") + .replaceAll("
", "") + .replaceAll("
", "") + .replaceAll("

", "") + .replaceAll("

", "") + .replaceAll("", "") + .replaceAll("", "") + + + System.getProperty("line.separator")); } is.close(); brs.close(); writerFile.close(); - //Путь для сохранения почти готового результата String pathBeforeSave = "C:/Users/" + userName + "/Desktop/" + textTitle + "NOT_FINAL" + ".txt"; @@ -267,21 +268,18 @@ public static void delete(String filePathIn, String filePathOut, int toRemove) { while ((currentLine = reader.readLine()) != null) { count++; if (count < toRemove) { - + continue; } if (count > toRemove) { if (first < 1) { - first++; - int length = currentLine.length(); - int symbol = currentLine.lastIndexOf(">") + 1; - String firstLine = currentLine.substring(symbol, length); + String firstLine = currentLine.replaceAll("data-is-adult=\"1\" itemprop=\"articleBody\">", ""); bufferWriter.write(firstLine + System.getProperty("line.separator")); - continue; + bufferWriter.write(System.getProperty("line.separator")); } if (first > 1) { bufferWriter.write(currentLine.trim() + System.getProperty("line.separator")); } - bufferWriter.write(currentLine.trim() + System.getProperty("line.separator")); + first++; } } bufferWriter.close(); @@ -306,7 +304,6 @@ public static void deleteSecond(String filePathIn, String filePathOut, int toRem if (count > toRemove) { } if (count <= toRemove) { - //linesBook.add(currentLine.trim() + System.getProperty("line.separator")); bufferWriter.write(currentLine.trim() + System.getProperty("line.separator")); } } @@ -345,7 +342,7 @@ public static int linesSecond(String filePathIn) { lineCount++; } reader.close(); - return lineCount - 2; + return lineCount - 2; //Зачем. Но лучше не трогать. } catch (Exception e) { e.printStackTrace(); }