0

I have an input file that looks like(without such big spaces between lines):

3 4

ATCGA

GACTTACA

AACTGTA

ATC

...and I need to concatenate all lines except for the first "3 4" line. Is there a simple solution? I've tried manipulating getline() somehow, but that has not worked for me.

Edit: The amount of lines will not be known initially, so it will have to be done recursively.

Chief
  • 39
  • 9
  • Possible duplicate of [Concatenate many rows into a single text string?](http://stackoverflow.com/questions/194852/concatenate-many-rows-into-a-single-text-string) – Alpesh Gediya Oct 15 '16 at 10:57

1 Answers1

0

If your concate 2 lines in 1 line then you can use easily concate "+",

e.g:

String a = "WAQAR MUGHAL";
String b = "check";

System.out.println(a + b);

System.out.println("WAQAR MUGHAL" + "CHECK");

Output:

WAQAR MUGHAL check
WAQAR MUGHAL CHECK
chalitha geekiyanage
  • 6,464
  • 5
  • 25
  • 32
  • I wish it were just that easy, but it is going to have to be some sort of loop to add each line, regardless of how many. – Chief Sep 23 '16 at 18:04
  • Use *StringBuffer* or *StringBuilder* based on requirement, above approach in not efficient in terms of implementation its solve problem but not recommended way.. – Alpesh Gediya Oct 15 '16 at 10:59