private static void insertText() throws IoTDBConnectionException, StatementExecutionException {
    String device = "root.sg1.text";
    // the first data is String type and the second data is Binary type
    List<Object> datas = Arrays.asList("String", new Binary("Binary", TSFileConfig.STRING_CHARSET));
    // insertRecord example
    for (int i = 0; i < datas.size(); i++) {
      // write data of String type or Binary type
      session.insertRecord(
          device,
          i,
          Collections.singletonList("s1"),
          Collections.singletonList(TSDataType.TEXT),
          datas.get(i));
    }

    // insertTablet example
    List<IMeasurementSchema> schemaList = new ArrayList<>();
    schemaList.add(new MeasurementSchema("s2", TSDataType.TEXT));
    Tablet tablet = new Tablet(device, schemaList, 100);
    for (int i = 0; i < datas.size(); i++) {
      int rowIndex = tablet.getRowSize();
      tablet.addTimestamp(rowIndex, i);
      //  write data of String type or Binary type
      tablet.addValue(schemaList.get(0).getMeasurementName(), rowIndex, datas.get(i));
    }
    session.insertTablet(tablet);
    try (SessionDataSet dataSet = session.executeQueryStatement("select s1, s2 from " + device)) {
      System.out.println(dataSet.getColumnNames());
      while (dataSet.hasNext()) {
        System.out.println(dataSet.next());
      }
    }
  }
This example shows how to insert data of TSDataType.TEXT. You can use the session interface to
write data of String type or Binary type.
example/session/src/main/java/org/apache/iotdb/SessionExample.java