XML字符串轉字節流轉BLOB

object 轉字節再轉BLOB

 						Object o = map.get(values.get(j));
                        byte[] bytes = null;
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        try {
                            ObjectOutputStream oos = new ObjectOutputStream(bos);
                            oos.writeObject(o);
                            oos.flush();
                            bytes = bos.toByteArray ();
                            oos.close();
                            bos.close();
                        } catch (IOException ex) {
                            ex.printStackTrace();
                        }
                        Blob bpmnBlob = new SerialBlob(bytes);

字符串轉字節轉BLOB

						String st = (String) map.get(values.get(j));
                        byte[] bpmnBytes = new byte[0];
                        try {
                            JsonNode editorNode = new ObjectMapper().readTree(st);
                            BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
                            BpmnModel model = jsonConverter.convertToBpmnModel(editorNode);
                             bpmnBytes = new BpmnXMLConverter().convertToXML(model);
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        Blob bpmnBlob = new SerialBlob(bpmnBytes);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章