Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import java.nio.charset.Charset; import android.nfc.NdefRecord; public class Main { private static NdefRecord createText(String paramString1, String paramString2) { int i = 0; try { ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(); DataOutputStream localDataOutputStream = new DataOutputStream(localByteArrayOutputStream); byte[] arrayOfByte1 = paramString2.getBytes(Charset.forName("US-ASCII")); byte[] arrayOfByte2 = paramString1.getBytes(Charset.forName("UTF-8")); localDataOutputStream.writeByte((byte) (char) (i + arrayOfByte1.length)); localDataOutputStream.write(arrayOfByte1); localDataOutputStream.write(arrayOfByte2); NdefRecord localNdefRecord = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], localByteArrayOutputStream.toByteArray()); return localNdefRecord; } catch (IOException localIOException) { throw new RuntimeException(localIOException); } } }