|
@@ -257,22 +257,47 @@ public class CreateObjUtil {
|
|
|
}
|
|
|
|
|
|
public static void convertTxtToDam(String srcpath,String despath)throws Exception{
|
|
|
- BigSceneProto.binary_mesh.Builder builder = BigSceneProto.binary_mesh.newBuilder();
|
|
|
- InputStream inputStream = new FileInputStream(srcpath);
|
|
|
- InputStreamReader reader = new InputStreamReader(inputStream, "ASCII");
|
|
|
- TextFormat.merge(reader, builder);
|
|
|
- byte[] buf = builder.build().toByteArray();
|
|
|
-
|
|
|
- //把序列化后的数据写入本地磁盘
|
|
|
- ByteArrayInputStream stream = new ByteArrayInputStream(buf);
|
|
|
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
|
|
|
- BufferedInputStream bis = new BufferedInputStream(stream);
|
|
|
- int b = -1;
|
|
|
- while ((b = bis.read()) != -1) {
|
|
|
- bos.write(b);
|
|
|
+ InputStream inputStream = null;
|
|
|
+ InputStreamReader reader = null;
|
|
|
+ ByteArrayInputStream stream = null;
|
|
|
+ BufferedOutputStream bos = null;
|
|
|
+ BufferedInputStream bis = null;
|
|
|
+ try{
|
|
|
+ BigSceneProto.binary_mesh.Builder builder = BigSceneProto.binary_mesh.newBuilder();
|
|
|
+ inputStream = new FileInputStream(srcpath);
|
|
|
+ reader = new InputStreamReader(inputStream, "ASCII");
|
|
|
+ TextFormat.merge(reader, builder);
|
|
|
+ byte[] buf = builder.build().toByteArray();
|
|
|
+
|
|
|
+ //把序列化后的数据写入本地磁盘
|
|
|
+ stream = new ByteArrayInputStream(buf);
|
|
|
+ bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
|
|
|
+ bis = new BufferedInputStream(stream);
|
|
|
+ int b = -1;
|
|
|
+ while ((b = bis.read()) != -1) {
|
|
|
+ bos.write(b);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("txt转dam出错,srcpath:{}, despath:{}",srcpath, despath);
|
|
|
+ throw e;
|
|
|
+ }finally {
|
|
|
+ if(inputStream != null){
|
|
|
+ inputStream.close();
|
|
|
+ }
|
|
|
+ if(reader != null){
|
|
|
+ reader.close();
|
|
|
+ }
|
|
|
+ if(stream != null){
|
|
|
+ stream.close();
|
|
|
+ }
|
|
|
+ if(bos != null){
|
|
|
+ bos.close();
|
|
|
+ }
|
|
|
+ if(bis != null){
|
|
|
+ bis.close();
|
|
|
+ }
|
|
|
}
|
|
|
- bis.close();
|
|
|
- bos.close();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public static void convertVisionmodeldataToTxt(String srcpath,String despath)throws Exception
|