FileUtil.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
17 package com.generalrobotix.ui.util;
18 
19 import java.io.*;
20 import java.nio.channels.*;
23 
24 public class FileUtil {
25 
35  public static void copyTransfer(String srcPath, String destPath)
36  throws IOException {
37 
38  FileChannel srcChannel = new FileInputStream(srcPath).getChannel();
39  FileChannel destChannel = new FileOutputStream(destPath).getChannel();
40  try {
41  srcChannel.transferTo(0, srcChannel.size(), destChannel);
42  } finally {
43  srcChannel.close();
44  destChannel.close();
45  }
46  }
47 
56  public static void resourceToFile(Class<? extends GrxPluginManager> grxPluginManager, String srcName, File destFile)
57  throws IOException {
58  InputStream in = grxPluginManager.getResourceAsStream(srcName.toString());
59  OutputStream out = new FileOutputStream(destFile.toString());
60  try {
61  byte[] buf = new byte[1024];
62  int len;
63  while ((len = in.read(buf)) > 0) {
64  out.write(buf, 0, len);
65  }
66  } catch (IOException e) {
67  e.printStackTrace();
68  } finally {
69  in.close();
70  out.close();
71  }
72  }
73 
77  public static void deleteNameServerLog(String logPath)
78  {
79  // log のクリア
80  String[] com;
81  if (System.getProperty("os.name").equals("Linux") || System.getProperty("os.name").equals("Mac OS X")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
82  com = new String[] { "/bin/sh", "-c", "rm " + logPath + File.separator + "*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
83  } else {
84  logPath = logPath.replaceFirst("^\"", "");
85  logPath = logPath.replaceFirst("\"$", "");
86  com = new String[] { "cmd", "/c", "del " + "\"" + logPath + File.separator + "omninames-*.*" + "\""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
87  }
88  try {
89  Process pr = Runtime.getRuntime().exec(com);
90  InputStream is = pr.getInputStream();
91  BufferedReader br = new BufferedReader(new InputStreamReader(is));
92  String line;
93  pr.waitFor();
94  while ((line = br.readLine()) != null) {
95  System.out.println(line);
96  }
97  } catch (Exception e) {
98  e.printStackTrace();
99  }
100  }
101 }
static void resourceToFile(Class<?extends GrxPluginManager > grxPluginManager, String srcName, File destFile)
Definition: FileUtil.java:56
#define null
our own NULL pointer
Definition: IceTypes.h:57
static void deleteNameServerLog(String logPath)
omniName サーバのログファイル削除
Definition: FileUtil.java:77
static void copyTransfer(String srcPath, String destPath)
コピー元のパス[srcPath]から、コピー先のパス[destPath]へ ファイルのコピーを行います。 コピー処理にはFi...
Definition: FileUtil.java:35
png_bytep buf
Definition: png.h:2729
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:21