java.io.IOException.initCause()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中java.io.IOException.initCause()方法的一些代码示例,展示了IOException.initCause()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOException.initCause()方法的具体详情如下:
包路径:java.io.IOException
类名称:IOException
方法名:initCause

IOException.initCause介绍

暂无

代码示例

代码示例来源:origin: Bukkit/Bukkit

private static IOException newIOException(String string, Throwable cause) {
    IOException exception = new IOException(string);
    exception.initCause(cause);
    return exception;
  }
}

代码示例来源:origin: apache/activemq

public static IOException create(String msg, Exception cause) {
  IOException exception = new IOException(msg);
  exception.initCause(cause);
  return exception;
}

代码示例来源:origin: apache/activemq

public static IOException create(String msg, Throwable cause) {
  IOException exception = new IOException(msg);
  exception.initCause(cause);
  return exception;
}

代码示例来源:origin: spotbugs/spotbugs

private static IOException newIOException(Object file, IOException e) {
  IOException result = new IOException("Failing reading " + file);
  result.initCause(e);
  return result;
}

代码示例来源:origin: spotbugs/spotbugs

public static IOException makeIOException(String msg, Throwable cause) {
  IOException e = new IOException(msg);
  e.initCause(cause);
  return e;
}
private static String getFileExtension(String name) {

代码示例来源:origin: spotbugs/spotbugs

public static void throwIOException(String msg, Throwable cause) throws IOException {
  IOException e = new IOException(msg);
  e.initCause(cause);
  throw e;
}

代码示例来源:origin: oracle/opengrok

/**
 * Wrap a {@code Throwable} in an {@code IOException} and return it.
 */
static IOException wrapInIOException(String message, Throwable t) {
  // IOException's constructor takes a Throwable, but only in JDK 6
  IOException ioe = new IOException(message + ": " + t.getMessage());
  ioe.initCause(t);
  return ioe;
}

代码示例来源:origin: apache/activemq

public static IOException create(Throwable cause) {
  IOException exception = new IOException(cause.getMessage());
  exception.initCause(cause);
  return exception;
}

代码示例来源:origin: apache/activemq

public static IOException create(Exception cause) {
  IOException exception = new IOException(cause.getMessage());
  exception.initCause(cause);
  return exception;
}

代码示例来源:origin: spotbugs/spotbugs

public LocalArchiveEntry(String fileName) throws IOException {
  try {
    zipFile = new ZipFile(fileName);
  } catch (IOException e) {
    IOException ioe = new IOException("Could not open archive file " + fileName);
    ioe.initCause(e);
    throw ioe;
  }
}

代码示例来源:origin: spotbugs/spotbugs

public void method() {
    try {
      new String(new byte[] {}, "xyz");
    } catch (UnsupportedEncodingException e) {
      IOException pe = new IOException("cannot parse URL query part");
      pe.initCause(e);
    }
  }
}

代码示例来源:origin: prestodb/presto

@Override public void connectSocket(Socket socket, InetSocketAddress address,
  int connectTimeout) throws IOException {
 try {
  socket.connect(address, connectTimeout);
 } catch (AssertionError e) {
  if (Util.isAndroidGetsocknameError(e)) throw new IOException(e);
  throw e;
 } catch (SecurityException e) {
  // Before android 4.3, socket.connect could throw a SecurityException
  // if opening a socket resulted in an EACCES error.
  IOException ioException = new IOException("Exception in connect");
  ioException.initCause(e);
  throw ioException;
 }
}

代码示例来源:origin: apache/zookeeper

public static IWatchManager createWatchManager() throws IOException {
    String watchManagerName = System.getProperty(ZOOKEEPER_WATCH_MANAGER_NAME);
    if (watchManagerName == null) {
      watchManagerName = WatchManager.class.getName();
    }
    try {
      IWatchManager watchManager =
          (IWatchManager) Class.forName(watchManagerName).newInstance();
      LOG.info("Using {} as watch manager", watchManagerName);
      return watchManager;
    } catch (Exception e) {
      IOException ioe = new IOException("Couldn't instantiate "
          + watchManagerName);
      ioe.initCause(e);
      throw ioe;
    }
  }
}

代码示例来源:origin: apache/zookeeper

static public ServerCnxnFactory createFactory() throws IOException {
  String serverCnxnFactoryName =
    System.getProperty(ZOOKEEPER_SERVER_CNXN_FACTORY);
  if (serverCnxnFactoryName == null) {
    serverCnxnFactoryName = NIOServerCnxnFactory.class.getName();
  }
  try {
    ServerCnxnFactory serverCnxnFactory = (ServerCnxnFactory) Class.forName(serverCnxnFactoryName)
        .getDeclaredConstructor().newInstance();
    LOG.info("Using {} as server connection factory", serverCnxnFactoryName);
    return serverCnxnFactory;
  } catch (Exception e) {
    IOException ioe = new IOException("Couldn't instantiate "
        + serverCnxnFactoryName);
    ioe.initCause(e);
    throw ioe;
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public <T extends Enum<T>> T readEnum(String name, Class<T> enumType,
        T defVal) throws IOException {
T ret = defVal;
try {
  String eVal = currentElem.getAttribute(name);
  if (eVal != null && eVal.length() > 0) {
    ret = Enum.valueOf(enumType, eVal);
  }
} catch (Exception e) {
  IOException io = new IOException(e.toString());
  io.initCause(e);
  throw io;
}
return ret;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public boolean readBoolean(String name, boolean defVal) throws IOException {
  String tmpString = currentElem.getAttribute(name);
  if (tmpString == null || tmpString.length() < 1) return defVal;
  try {
    return Boolean.parseBoolean(tmpString);
  } catch (DOMException de) {
    IOException io = new IOException(de.toString());
    io.initCause(de);
    throw io;
  }
}

代码示例来源:origin: robovm/robovm

public IOException rethrowAsIOException() throws IOException {
  IOException newException = new IOException(getMessage());
  newException.initCause(this);
  throw newException;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public Savable load(InputStream f) throws IOException {
  try {
    domIn = new DOMInputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f), this);
    return domIn.readSavable(null, null);
  } catch (SAXException e) {
    IOException ex = new IOException();
    ex.initCause(e);
    throw ex;
  } catch (ParserConfigurationException e) {
    IOException ex = new IOException();
    ex.initCause(e);
    throw ex;
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public void write(final int b) throws IOException {
 writeBuffer[writePointer] = (byte) (b & 0xFF);
 writePointer++;
 if (writePointer == writeBuffer.length) {
   writePointer = 0;
   try {
    doWrite();
   } catch (DataFormatException e) {
    IOException ie = new IOException("Error decompressing data");
    ie.initCause(e);
    throw ie;
   }
 }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public short readShort(String name, short defVal) throws IOException {
  String tmpString = currentElem.getAttribute(name);
  if (tmpString == null || tmpString.length() < 1) return defVal;
  try {
    return Short.parseShort(tmpString);
  } catch (NumberFormatException nfe) {
    IOException io = new IOException(nfe.toString());
    io.initCause(nfe);
    throw io;
  } catch (DOMException de) {
    IOException io = new IOException(de.toString());
    io.initCause(de);
    throw io;
  }
}

相关文章