I suggest you to read your first file then read template file which has your format and replace for example $VCARDNO$ from this template with your number then save the new format after replacement.
For read file, you can read this How can I read a text file in Android? or search on it.
For write to file, you can read this How To Read/Write String From A File In Android or search on it.
You can make the following:
1- Create template file (or template string) has the following format and save it:
BEGIN:VCARD
VERSION:2.1
N:;UNKNOWN 1;;;
FN:UNKNOWN 1
TEL;CELL;PREF:$REALVCARDNO$
END:VCARD
2- Read your card number files and load them to list for example.
3- Read the template file and keep it fixed.
4- Loop on the list and take the value which you read it from the template file then replace $REALVCARDNO$ with the current value on the list and save the new value in the output file which you need.
If you decide to change the file format later based on new requirement, you will change only in the template without making any change in the code.
Example in code:
private void processTemplate() {
final String template = "BEGIN:VCARD" + "\n" + "VERSION:2.1" + "\n" + "N:;UNKNOWN 1;;;" + "\n" + "FN:UNKNOWN 1" + "\n" + "TEL;CELL;PREF:$REALVCARDNO$" + "\n" + "END:VCARD";
List<String> cardNumberList = new ArrayList<String>();
//here you should read your file which has the card number and fill cardNumberList with it instead of the following two lines
cardNumberList.add("3456854778");
cardNumberList.add("3545456634");
for (String cardNo : cardNumberList) {
String myNewStringToSave = template.replace("$REALVCARDNO$", cardNo);
//here you can save myNewStringToSave to file if you need to save each card number with the above format in single file
}
}