private String setHeader (String key, int datalen, Map header) {

        String info = separator + key;
        if (header != null && header.containsKey("dtime")) {
            info += separator + "dtime=" + header.get("dtime");
            header.remove("dtime");
        } else {
            info += separator + "dtime=" + new Date();
        }

        if (header != null && header.size() > 0) {
            Iterator it = header.entrySet().iterator();
            String item;
            while (it.hasNext()) {
                Map.Entry pairs = (Map.Entry)it.next();
                item = pairs.getKey() + "=" + pairs.getValue();
                //todo CG
                try {
                    item = new String(item.getBytes("UTF8"));
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }

                if (!item.contains(separator)) {
                    info += separator + item.trim();
                } else {
                    info += separator + item.replaceAll(separator,"#_").trim();
                }
            }
            info = info.replaceAll("[\n|\r]+"," ");

        }


        return info + separator + datalen +"\n";

    }