当前位置: 首页>>代码示例>>Java>>正文


Java IOException类代码示例

本文整理汇总了Java中java.io.IOException的典型用法代码示例。如果您正苦于以下问题:Java IOException类的具体用法?Java IOException怎么用?Java IOException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IOException类属于java.io包,在下文中一共展示了IOException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFrames

import java.io.IOException; //导入依赖的package包/类
static ArrayList<BufferedImage> getFrames(File gif) throws IOException {
    ArrayList<BufferedImage> frames = new ArrayList<BufferedImage>();
    ImageReader ir = new GIFImageReader(new GIFImageReaderSpi());
    ir.setInput(ImageIO.createImageInputStream(gif));
    for (int i = 0; i < ir.getNumImages(true); i++) {
        frames.add(ir.read(i));
    }
    // Release resources for Garbage Collection
    ir.dispose();
    return frames;
}
 
开发者ID:phweda,项目名称:MFM,代码行数:12,代码来源:VideoUtils.java

示例2: getSamples

import java.io.IOException; //导入依赖的package包/类
public List<ByteBuffer> getSamples() {
    List<ByteBuffer> samples = new LinkedList<ByteBuffer>();
    long lastEnd = 0;
    for (Line sub : subs) {
        long silentTime = sub.from - lastEnd;
        if (silentTime > 0) {
            samples.add(ByteBuffer.wrap(new byte[]{0, 0}));
        } else if (silentTime < 0) {
            throw new Error("Subtitle display times may not intersect");
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);
        try {
            dos.writeShort(sub.text.getBytes("UTF-8").length);
            dos.write(sub.text.getBytes("UTF-8"));
            dos.close();
        } catch (IOException e) {
            throw new Error("VM is broken. Does not support UTF-8");
        }
        samples.add(ByteBuffer.wrap(baos.toByteArray()));
        lastEnd = sub.to;
    }
    return samples;
}
 
开发者ID:begeekmyfriend,项目名称:mp4parser_android,代码行数:25,代码来源:QuicktimeTextTrackImpl.java

示例3: getObservableAddressFromLocation

import java.io.IOException; //导入依赖的package包/类
public Observable<Address> getObservableAddressFromLocation(final double latitude, final double longitude,
                                                            final Context context) {
    return new Observable<Address>() {
        @Override
        protected void subscribeActual(Observer<? super Address> observer) {
            Geocoder geocoder = new Geocoder(context, Locale.getDefault());
            try {
                List<Address> addressList = geocoder.getFromLocation(
                        latitude, longitude, 1);
                if (addressList != null && addressList.size() > 0) {
                    address = addressList.get(0);
                    observer.onNext(address);
                }
            } catch (IOException e) {
                Log.e(TAG, "Unable connect to Geocoder", e);
            }

        }
    }.subscribeOn(Schedulers.newThread())
            .observeOn(AndroidSchedulers.mainThread());
}
 
开发者ID:aliumujib,项目名称:Nibo,代码行数:22,代码来源:LocationAddress.java

示例4: writeObject

import java.io.IOException; //导入依赖的package包/类
private void writeObject(ObjectOutputStream s)
    throws IOException
{
    Iterator<Map.Entry<K,V>> i =
        (size > 0) ? entrySet0().iterator() : null;

    // Write out the threshold, loadfactor, and any hidden stuff
    s.defaultWriteObject();

    // Write out number of buckets
    s.writeInt(table.length);

    // Write out size (number of Mappings)
    s.writeInt(size);

    // Write out keys and values (alternating)
    if (i != null) {
        while (i.hasNext()) {
            Map.Entry<K,V> e = i.next();
            s.writeObject(e.getKey());
            s.writeObject(e.getValue());
        }
    }
}
 
开发者ID:DStream-Storm,项目名称:DStream,代码行数:25,代码来源:SynopsisHashMap.java

示例5: _renderParagraph

import java.io.IOException; //导入依赖的package包/类
/**
 * Renders the currently opened paragraph with the currently buffered content,
 * escaping it if necessary, then close it and flush the buffer.
 *
 * @param rw      the response writer used to put content in the underlying
 *                response.
 * @param bean    the property holder for the rendered document.
 * @param builder the content buffer
 *
 * @throws IOException if a problem occurs while writing the content to the
 *                     underlying response.
 */
private void _renderParagraph(
  FacesContext  context,
  StringBuilder builder
  ) throws IOException
{
  // Pre-conditions that would cause NullPointerException if not met
  assert builder != null;
  assert context != null;

  renderFormattedText(context, builder.toString());

  context.getResponseWriter().endElement(_PARAGRAPH_ELEMENT);

  // Clear buffer content
  builder.delete(0, builder.length());
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:29,代码来源:OutputDocumentRenderer.java

示例6: testServerNotAvailable

import java.io.IOException; //导入依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@CompareDefaultWithCronet
public void testServerNotAvailable() throws Exception {
    URL url = new URL(NativeTestServer.getFileURL("/success.txt"));
    HttpURLConnection urlConnection =
            (HttpURLConnection) url.openConnection();
    assertEquals("this is a text file\n", TestUtil.getResponseAsString(urlConnection));
    // After shutting down the server, the server should not be handling
    // new requests.
    NativeTestServer.shutdownNativeTestServer();
    HttpURLConnection secondConnection =
            (HttpURLConnection) url.openConnection();
    // Default implementation reports this type of error in connect().
    // However, since Cronet's wrapper only receives the error in its listener
    // callback when message loop is running, Cronet's wrapper only knows
    // about the error when it starts to read response.
    try {
        secondConnection.getResponseCode();
        fail();
    } catch (IOException e) {
        assertTrue(e instanceof java.net.ConnectException
                || e instanceof UrlRequestException);
        assertTrue((e.getMessage().contains("ECONNREFUSED")
                || (e.getMessage().contains("Connection refused"))
                || e.getMessage().contains("net::ERR_CONNECTION_REFUSED")));
    }
    checkExceptionsAreThrown(secondConnection);
    // Starts the server to avoid crashing on shutdown in tearDown().
    assertTrue(NativeTestServer.startNativeTestServer(getContext()));
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:32,代码来源:CronetHttpURLConnectionTest.java

示例7: tryOpen

import java.io.IOException; //导入依赖的package包/类
/**
 * Try to open the file from one of the available locations.
 *
 * @return FSDataInputStream stream of the opened file link
 * @throws IOException on unexpected error, or file not found.
 */
private FSDataInputStream tryOpen() throws IOException {
  for (Path path: fileLink.getLocations()) {
    if (path.equals(currentPath)) continue;
    try {
      in = fs.open(path, bufferSize);
      if (pos != 0) in.seek(pos);
      assert(in.getPos() == pos) : "Link unable to seek to the right position=" + pos;
      if (LOG.isTraceEnabled()) {
        if (currentPath == null) {
          LOG.debug("link open path=" + path);
        } else {
          LOG.trace("link switch from path=" + currentPath + " to path=" + path);
        }
      }
      currentPath = path;
      return(in);
    } catch (FileNotFoundException e) {
      // Try another file location
    }
  }
  throw new FileNotFoundException("Unable to open link: " + fileLink);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:FileLink.java

示例8: _decode

import java.io.IOException; //导入依赖的package包/类
private void _decode(AsnInputStream ais, int length) throws MAPParsingComponentException, IOException, AsnException {

        this.gsmSecurityContextData = null;
        this.umtsSecurityContextData = null;

        int tag = ais.getTag();

        if (ais.getTagClass() != Tag.CLASS_CONTEXT_SPECIFIC || ais.isTagPrimitive())
            throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName
                    + ": Primitive has bad tag class or is primitive", MAPParsingComponentExceptionReason.MistypedParameter);

        switch (tag) {
            case _TAG_gsmSecurityContextData:
                this.gsmSecurityContextData = new GSMSecurityContextDataImpl();
                ((GSMSecurityContextDataImpl) this.gsmSecurityContextData).decodeData(ais, length);
                break;
            case _TAG_umtsSecurityContextData:
                this.umtsSecurityContextData = new UMTSSecurityContextDataImpl();
                ((UMTSSecurityContextDataImpl) this.umtsSecurityContextData).decodeData(ais, length);
                break;

            default:
                throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ": bad choice tag",
                        MAPParsingComponentExceptionReason.MistypedParameter);
        }
    }
 
开发者ID:RestComm,项目名称:phone-simulator,代码行数:27,代码来源:CurrentSecurityContextImpl.java

示例9: startAM

import java.io.IOException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void startAM() throws YarnException, IOException {
  // application/container configuration
  int heartbeatInterval = conf.getInt(
          SLSConfiguration.AM_HEARTBEAT_INTERVAL_MS,
          SLSConfiguration.AM_HEARTBEAT_INTERVAL_MS_DEFAULT);
  int containerMemoryMB = conf.getInt(SLSConfiguration.CONTAINER_MEMORY_MB,
          SLSConfiguration.CONTAINER_MEMORY_MB_DEFAULT);
  int containerVCores = conf.getInt(SLSConfiguration.CONTAINER_VCORES,
          SLSConfiguration.CONTAINER_VCORES_DEFAULT);
  Resource containerResource =
          BuilderUtils.newResource(containerMemoryMB, containerVCores);

  // application workload
  if (isSLS) {
    startAMFromSLSTraces(containerResource, heartbeatInterval);
  } else {
    startAMFromRumenTraces(containerResource, heartbeatInterval);
  }
  numAMs = amMap.size();
  remainingApps = numAMs;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:SLSRunner.java

示例10: unknownHostEmits

import java.io.IOException; //导入依赖的package包/类
@Test
public void unknownHostEmits() throws IOException, InterruptedException {
  SendsStuff api = Feign.builder()
      .logger(logger)
      .logLevel(logLevel)
      .retryer(new Retryer() {
        @Override
        public void continueOrPropagate(RetryableException e) {
          throw e;
        }
        @Override public Retryer clone() {
            return this;
        }
      })
      .target(SendsStuff.class, "http://robofu.abc");

  thrown.expect(FeignException.class);

  api.login("netflix", "denominator", "password");
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:21,代码来源:LoggerTest.java

示例11: doGet

import java.io.IOException; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	LOGGER.debug("Finding token to revoke ...");
	String token = req.getParameter("token");
	if (!Preconditions.isEmptyString(token)) {
		try {
			this.service.revokeToken(token);
		} catch (UnrecoverableOAuthException e) {
			OAuthError err = e.getError();
			LOGGER.warn(String.format("Unable to revoke token %s because [%s]%s", token, err.getName(), err.getDescription()));
		}
	} else {
		LOGGER.debug("No token found in parameter, skipping ...");
	}
	this.postSignOut(req, resp);
}
 
开发者ID:sgr-io,项目名称:social-signin,代码行数:17,代码来源:GooglePlusDisconnectServlet.java

示例12: checkIfModifiedSince

import java.io.IOException; //导入依赖的package包/类
/**
 * Check if the if-modified-since condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceInfo File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request 
 * processing is stopped
 */
private boolean checkIfModifiedSince(HttpServletRequest request,
                                     HttpServletResponse response,
                                     ResourceInfo resourceInfo)
    throws IOException {
    try {
        long headerValue = request.getDateHeader("If-Modified-Since");
        long lastModified = resourceInfo.date;
        if (headerValue != -1) {

            // If an If-None-Match header has been specified, if modified since
            // is ignored.
            if ((request.getHeader("If-None-Match") == null) 
                && (lastModified <= headerValue + 1000)) {
                // The entity has not been modified since the date
                // specified by the client. This is not an error case.
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                return false;
            }
        }
    } catch(IllegalArgumentException illegalArgument) {
        return false;
    }
    return true;

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:36,代码来源:DefaultServlet.java

示例13: onRunStep

import java.io.IOException; //导入依赖的package包/类
@Override
protected void onRunStep() throws SetupStepException {
    try {
        log.d("Ensuring connection to AP");
        workerThreadApConnector.ensureConnectionToSoftAp();

        log.d("Sending connect-ap command");
        ConnectAPCommand.Response response = commandClient.sendCommand(
                // FIXME: is hard-coding zero here correct?  If so, document why
                new ConnectAPCommand(0), ConnectAPCommand.Response.class);
        if (!response.isOK()) {
            throw new SetupStepException("ConnectAPCommand returned non-zero response code: " +
                    response.responseCode);
        }

        commandSent = true;

    } catch (IOException e) {
        throw new SetupStepException(e);
    }
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:22,代码来源:ConnectDeviceToNetworkStep.java

示例14: parseSoliditySource

import java.io.IOException; //导入依赖的package包/类
private String parseSoliditySource(String includedFile) throws MojoExecutionException {
    try {
        byte[] contract = Files.readAllBytes(Paths.get(soliditySourceFiles.getDirectory(), includedFile));
        CompilerResult result = SolidityCompiler.getInstance(getLog()).compileSrc(
                contract,
                SolidityCompiler.Options.ABI,
                SolidityCompiler.Options.BIN,
                SolidityCompiler.Options.INTERFACE,
                SolidityCompiler.Options.METADATA
        );
        if (result.isFailed()) {
            throw new MojoExecutionException("Could not compile solidity files\n" + result.errors);
        }

        getLog().debug("\t\tResult:\t" + result.output);
        getLog().debug("\t\tError: \t" + result.errors);
        return result.output;
    } catch (IOException ioException) {
        throw new MojoExecutionException("Could not compile files", ioException);
    }
}
 
开发者ID:web3j,项目名称:web3j-maven-plugin,代码行数:22,代码来源:JavaClassGeneratorMojo.java

示例15: process

import java.io.IOException; //导入依赖的package包/类
/**
 * @see SSICommand
 */
@Override
public long process(SSIMediator ssiMediator, String commandName,
        String[] paramNames, String[] paramValues, PrintWriter writer) {
    long lastModified = 0;
    String configErrMsg = ssiMediator.getConfigErrMsg();
    for (int i = 0; i < paramNames.length; i++) {
        String paramName = paramNames[i];
        String paramValue = paramValues[i];
        String substitutedValue = ssiMediator
                .substituteVariables(paramValue);
        try {
            if (paramName.equalsIgnoreCase("file")
                    || paramName.equalsIgnoreCase("virtual")) {
                boolean virtual = paramName.equalsIgnoreCase("virtual");
                lastModified = ssiMediator.getFileLastModified(
                        substitutedValue, virtual);
                Date date = new Date(lastModified);
                String configTimeFmt = ssiMediator.getConfigTimeFmt();
                writer.write(formatDate(date, configTimeFmt));
            } else {
                ssiMediator.log("#flastmod--Invalid attribute: "
                        + paramName);
                writer.write(configErrMsg);
            }
        } catch (IOException e) {
            ssiMediator.log(
                    "#flastmod--Couldn't get last modified for file: "
                            + substitutedValue, e);
            writer.write(configErrMsg);
        }
    }
    return lastModified;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:37,代码来源:SSIFlastmod.java


注:本文中的java.io.IOException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。