Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Input:
- 2
- Ophelia
- him
- Output:
- ACT I
- ACT I
- SCENE I. Elsinore. A platform before the castle.
- SCENE I. Elsinore. A platform before the castle.
- FRANCISCO at his post. Enter to him BERNARDO
- FRANCISCO at his post. Enter to *him* BERNARDO
- static void bold( char bold, BufferedReader orders, BufferedReader in,BufferedWriter out ) throws IOException{
- String linha = in.readLine();
- boolean encontrou = false;
- String[] palavras = new String[Integer.parseInt(orders.readLine())];
- for(int i = 0; i < palavras.length; i++){
- palavras[i]=orders.readLine();
- }
- while(linha != null){
- StringBuilder str = new StringBuilder(linha);
- for(int i = 0; i < palavras.length && !encontrou; i++){
- if(linha.toLowerCase().indexOf(palavras[i]) != -1){
- str.insert((linha.toLowerCase().indexOf(palavras[i])),bold);
- str.insert((linha.toLowerCase().indexOf(palavras[i]))+palavras[i].length()+1, bold);
- out.write(str.toString());
- out.newLine();
- }
- else{
- out.write(linha);
- out.newLine();
- }
- }
- linha = in.readLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement