2016-02-22 2 views
-1

Je souhaite écrire le code pour extraire le paragraphe après chaque en-tête.extraction des rubriques suivies du texte

Par exemple, considérons le document d'entrée suivante:

Test boîte noire

La technique de test sans avoir aucune connaissance du fonctionnement intérieur de l'application est appelée test boîte noire.

Test boîte blanche

test boîte blanche est l'enquête détaillée de la logique interne et la structure du code.

Test Gray-Box

test Gray-box est une technique pour tester l'application d'avoir une connaissance limitée du fonctionnement interne d'une application.

En sortie, je veux trois paragraphes distincts avec leur rubrique correspondante = association:

output 1 Black-Box Testing 

The technique of testing without having any knowledge of the interior workings of the application is called black-box testing. 

output 2 White-Box Testing 

White-box testing is the detailed investigation of internal logic and structure of the code. 

output 3 Grey-Box Testing 

Grey-box testing is a technique to test the application with having a limited knowledge of the internal workings of an application. 

S'il vous plaît guider.

+0

Quel type de recherche/efforts que vous avez fait afin de le résoudre par vous-même? – aribeiro

+0

De vous a fourni un exemple de texte flottant, il n'est pas évident que vous sépariez l'en-tête du texte de paragraphe. – SubOptimal

Répondre

0

Vous pouvez diviser le document avec « \ n »:
La sortie doit être un tableau avec 6 éléments

String[] parts = document.split("\\n"); 
String part1 = parts[0]; // Black-Box Testing 
String part2 = parts[1]; // The technique of testin... 
String part3 = parts[2]; // White-Box Testing 
String part4 = parts[3]; // White-box testing is the... 
... 
...