VDT2
@VDT2
Java

Как стирать строки из файла по маске?

Возможно не корректно задал вопрос.... Но.
Есть файл забитый вот такими "блоками"
class Fishing_splash_Soundshader : baseCharacter_SoundShader {
		samples[] = {{"DZ\sounds\Characters\actions\misc\fishing_splash_0", 1}, {"DZ\sounds\Characters\actions\misc\fishing_splash_1", 1}, {"DZ\sounds\Characters\actions\misc\fishing_splash_2", 1}};
		volume = 0.562341;
	};
	
	class Fishing_splash_small_Soundshader : baseCharacter_SoundShader {
		samples[] = {{"DZ\sounds\Characters\actions\misc\fishing_splash_small_0", 1}};
		volume = 0.562341;
	};
	
	class Fish_struggling_Soundshader : baseCharacter_SoundShader {
		samples[] = {{"DZ\sounds\Characters\actions\misc\fish_struggling_0", 1}, {"DZ\sounds\Characters\actions\misc\fish_struggling_1", 1}};
		volume = 0.562341;
	};


У меня есть № строки указывающий к примеру на "samples[] = {{"DZ\sounds\Characters\actions\misc\fishing_splash_small_0", 1}};" - средняя строка второго блока класса.

Накидал мелкий код по удалению конкретной строки (num) из файла
BufferedReader reader = new BufferedReader(new FileReader(sourceFile));
        BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
        String line;
        int lineNumber = 0;
        while ((line = reader.readLine()) != null) {
            lineNumber++;
            if (lineNumber != num) {
                writer.write(line);
                writer.newLine();
            }
        }
        reader.close();
        writer.close();


И вот задумался. А как "объяснить" программе чтобы она удаляла весь блок
class Fishing_splash_small_Soundshader : baseCharacter_SoundShader {
		samples[] = {{"DZ\sounds\Characters\actions\misc\fishing_splash_small_0", 1}};
		volume = 0.562341;
	};

если № строки попадает в любую его часть....

Может в java stream что есть для подобных задач?
Как решить такой вопрос?

Спасибо за любую наводку.
  • Вопрос задан
  • 32 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы