本文整理汇总了Java中java.io.IOException.initCause方法的典型用法代码示例。如果您正苦于以下问题:Java IOException.initCause方法的具体用法?Java IOException.initCause怎么用?Java IOException.initCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.IOException
的用法示例。
在下文中一共展示了IOException.initCause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: abort
import java.io.IOException; //导入方法依赖的package包/类
/**
* Abort the application and wait for it to finish.
* @param t the exception that signalled the problem
* @throws IOException A wrapper around the exception that was passed in
*/
void abort(Throwable t) throws IOException {
LOG.info("Aborting because of " + StringUtils.stringifyException(t));
try {
downlink.abort();
downlink.flush();
} catch (IOException e) {
// IGNORE cleanup problems
}
try {
handler.waitForFinish();
} catch (Throwable ignored) {
process.destroy();
}
IOException wrapper = new IOException("pipe child exception");
wrapper.initCause(t);
throw wrapper;
}
示例2: getShellVariables
import java.io.IOException; //导入方法依赖的package包/类
/**
* @return Map with a shell variable name as a key and variable
* value as value. The shell variables will be made
* avaiable to the build commands.
* <p/>
* This is a default implementation that returns an
* empty map.
* @see BuildScriptGenerator#addVariables(Map)
*/
public Map getShellVariables() throws IOException {
try {
final HashMap result = new HashMap(3);
final List depotPaths = getDepotPaths();
final StringBuffer sb = new StringBuffer(500);
for (int i = 0; i < depotPaths.size(); i++) {
final String path = (String) depotPaths.get(i);
sb.append(path).append(";");
}
result.put(PARABUILD_SVN_REPOSITORY_PATH, sb);
return result;
} catch (BuildException e) {
final IOException ioe = new IOException();
ioe.initCause(e);
throw ioe;
}
}
示例3: createFactory
import java.io.IOException; //导入方法依赖的package包/类
/**
* since 3.4.0,引入Netty;可以通过配置文件的zookeeper.serverCnxnFactory选项选择用
* zk自己实现的NIO;还是使用Netty框架
*/
static public ServerCnxnFactory createFactory() throws IOException {
String serverCnxnFactoryName =
System.getProperty(ZOOKEEPER_SERVER_CNXN_FACTORY);
if (serverCnxnFactoryName == null) {
serverCnxnFactoryName = NIOServerCnxnFactory.class.getName();
}
try {
//得到类的全路径包名;通过类加载,反射的方式简洁的实现简单工厂模式;而避免if,else判断的方式
return (ServerCnxnFactory) Class.forName(serverCnxnFactoryName)
.newInstance();
} catch (Exception e) {
IOException ioe = new IOException("Couldn't instantiate "
+ serverCnxnFactoryName);
ioe.initCause(e);
throw ioe;
}
}
示例4: flush
import java.io.IOException; //导入方法依赖的package包/类
public final void flush() throws IOException{
try{
orbStream.flush();
} catch(Error e) {
IOException ioexc = new IOException(e.getMessage());
ioexc.initCause(e) ;
throw ioexc ;
}
}
示例5: getClass
import java.io.IOException; //导入方法依赖的package包/类
/** Return the class for a name. Default is {@link Class#forName(String)}.*/
public static synchronized Class<?> getClass(String name, Configuration conf
) throws IOException {
Class<?> writableClass = NAME_TO_CLASS.get(name);
if (writableClass != null)
return writableClass.asSubclass(Writable.class);
try {
return conf.getClassByName(name);
} catch (ClassNotFoundException e) {
IOException newE = new IOException("WritableName can't load class: " + name);
newE.initCause(e);
throw newE;
}
}
示例6: readResponseHeaders
import java.io.IOException; //导入方法依赖的package包/类
@Override public Response.Builder readResponseHeaders(boolean expectContinue) throws IOException {
if (state != STATE_OPEN_REQUEST_BODY && state != STATE_READ_RESPONSE_HEADERS) {
throw new IllegalStateException("state: " + state);
}
try {
StatusLine statusLine = StatusLine.parse(source.readUtf8LineStrict());
Response.Builder responseBuilder = new Response.Builder()
.protocol(statusLine.protocol)
.code(statusLine.code)
.message(statusLine.message)
.headers(readHeaders());
if (expectContinue && statusLine.code == HTTP_CONTINUE) {
return null;
}
state = STATE_OPEN_RESPONSE_BODY;
return responseBuilder;
} catch (EOFException e) {
// Provide more context if the server ends the stream before sending a response.
IOException exception = new IOException("unexpected end of stream on " + streamAllocation);
exception.initCause(e);
throw exception;
}
}
示例7: checkConfig
import java.io.IOException; //导入方法依赖的package包/类
/**
* Checks that the certificate is compatible with the enabled cipher suites.
* If we don't check now, the JIoEndpoint can enter a nasty logging loop.
* See bug 45528.
*/
private void checkConfig() throws IOException {
// Create an unbound server socket
ServerSocket socket = sslProxy.createServerSocket();
initServerSocket(socket);
try {
// Set the timeout to 1ms as all we care about is if it throws an
// SSLException on accept.
socket.setSoTimeout(1);
socket.accept();
// Will never get here - no client can connect to an unbound port
} catch (SSLException ssle) {
// SSL configuration is invalid. Possibly cert doesn't match ciphers
IOException ioe = new IOException(sm.getString(
"jsse.invalid_ssl_conf", ssle.getMessage()));
ioe.initCause(ssle);
throw ioe;
} catch (Exception e) {
/*
* Possible ways of getting here
* socket.accept() throws a SecurityException
* socket.setSoTimeout() throws a SocketException
* socket.accept() throws some other exception (after a JDK change)
* In these cases the test won't work so carry on - essentially
* the behaviour before this patch
* socket.accept() throws a SocketTimeoutException
* In this case all is well so carry on
*/
} finally {
// Should be open here but just in case
if (!socket.isClosed()) {
socket.close();
}
}
}
示例8: generate
import java.io.IOException; //导入方法依赖的package包/类
/**
* Performs the generation of entity classes.
*
* @param progressContributor the progress contributor for the generation process.
*
* @return a set of <code>FileObject</code>s representing the generated entity
* classes.
* @throws SQLException in case an error was encountered when connecting to the db.
* @throws IOException in case the writing of the generated entities fails.
*/
public Set<FileObject> generate(ProgressContributor progressContributor) throws SQLException, IOException{
RelatedCMPHelper helper = new RelatedCMPHelper(project, PersistenceLocation.getLocation(project, location.getRootFolder()), generator);
helper.setLocation(location);
helper.setPackageName(packageName);
try{
TableClosure tableClosure = getTableClosure();
SelectedTables selectedTables = new SelectedTables(generator, tableClosure, location, packageName);
helper.setTableClosure(tableClosure);
helper.setTableSource(getSchemaElement(), null);
helper.setSelectedTables(selectedTables);
helper.setGenerateFinderMethods(generateNamedQueries);
helper.setFullyQualifiedTableNames(fullyQualifiedTableNames);
helper.setRegenTablesAttrs(regenTableAttrs);
helper.setFetchType(fetchType);
helper.setCollectionType(collectionType);
helper.buildBeans();
} catch (DBException ex){
IOException wrapper = new IOException(ex.getMessage());
wrapper.initCause(ex);
throw wrapper;
}
generator.generateBeans(null, helper, null, progressContributor);
Set<FileObject> result = generator.createdObjects();
return result;
}
示例9: replaceObject
import java.io.IOException; //导入方法依赖的package包/类
/**
* Checks for objects that are instances of java.rmi.Remote
* that need to be serialized as proxy (Stub) objects.
*/
protected final Object replaceObject(Object obj) throws IOException {
try {
if ((obj instanceof java.rmi.Remote) &&
!(StubAdapter.isStub(obj))) {
return Utility.autoConnect(obj, orb, true);
}
} catch (Exception e) {
IOException ie = new IOException("replaceObject failed");
ie.initCause(e);
throw ie;
}
return obj;
}
示例10: NegotiatorImpl
import java.io.IOException; //导入方法依赖的package包/类
/**
* Constructor
* @throws java.io.IOException If negotiator cannot be constructed
*/
public NegotiatorImpl(HttpCallerInfo hci) throws IOException {
try {
init(hci);
} catch (GSSException e) {
if (DEBUG) {
System.out.println("Negotiate support not initiated, will " +
"fallback to other scheme if allowed. Reason:");
e.printStackTrace();
}
IOException ioe = new IOException("Negotiate support not initiated");
ioe.initCause(e);
throw ioe;
}
}
示例11: readUTF
import java.io.IOException; //导入方法依赖的package包/类
public final String readUTF() throws IOException{
try{
readObjectState.readData(this);
return internalReadUTF(orbStream);
} catch (MARSHAL marshalException) {
handleOptionalDataMarshalException(marshalException, false);
throw marshalException;
} catch(Error e) {
IOException exc = new IOException(e.getMessage());
exc.initCause(e);
throw exc ;
}
}
示例12: readUnsignedByte
import java.io.IOException; //导入方法依赖的package包/类
public final int readUnsignedByte() throws IOException{
try{
readObjectState.readData(this);
return (orbStream.read_octet() << 0) & 0x000000FF;
} catch (MARSHAL marshalException) {
handleOptionalDataMarshalException(marshalException, false);
throw marshalException;
} catch(Error e) {
IOException exc = new IOException(e.getMessage());
exc.initCause(e);
throw exc ;
}
}
示例13: connectSocket
import java.io.IOException; //导入方法依赖的package包/类
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 e2) {
IOException ioException = new IOException("Exception in connect");
ioException.initCause(e2);
throw ioException;
}
}
示例14: encodeJobHistoryFileName
import java.io.IOException; //导入方法依赖的package包/类
/**
* Helper function to encode the URL of the filename of the job-history
* log file.
*
* @param logFileName file name of the job-history file
* @return URL encoded filename
* @throws IOException
*/
public static String encodeJobHistoryFileName(String logFileName)
throws IOException {
String replacementDelimiterEscape = null;
// Temporarily protect the escape delimiters from encoding
if (logFileName.contains(DELIMITER_ESCAPE)) {
replacementDelimiterEscape = nonOccursString(logFileName);
logFileName = logFileName.replaceAll(DELIMITER_ESCAPE, replacementDelimiterEscape);
}
String encodedFileName = null;
try {
encodedFileName = URLEncoder.encode(logFileName, "UTF-8");
} catch (UnsupportedEncodingException uee) {
IOException ioe = new IOException();
ioe.initCause(uee);
ioe.setStackTrace(uee.getStackTrace());
throw ioe;
}
// Restore protected escape delimiters after encoding
if (replacementDelimiterEscape != null) {
encodedFileName = encodedFileName.replaceAll(replacementDelimiterEscape, DELIMITER_ESCAPE);
}
return encodedFileName;
}
示例15: getOutputStream
import java.io.IOException; //导入方法依赖的package包/类
public java.io.OutputStream getOutputStream (FileLock lock) throws IOException {
if (openStreams != 0) {
IOException e = new IOException("There is stream already, cannot write down!");
if (previousStream != null) {
e.initCause(previousStream);
}
throw e;
}
class ContentStream extends java.io.ByteArrayOutputStream {
public ContentStream() {
openStreams = -1;
}
@Override
public void close () throws java.io.IOException {
if (openStreams != -1) {
IOException ex = new IOException("One output stream");
ex.initCause(previousStream);
throw ex;
}
//assertEquals("One output stream", -1, openStreams);
openStreams = 0;
previousStream = new Exception("Closed");
super.close ();
RUNNING.content = new String (toByteArray ());
}
}
previousStream = new Exception("Output");
return new ContentStream ();
}