本文整理汇总了Java中java.io.UncheckedIOException类的典型用法代码示例。如果您正苦于以下问题:Java UncheckedIOException类的具体用法?Java UncheckedIOException怎么用?Java UncheckedIOException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UncheckedIOException类属于java.io包,在下文中一共展示了UncheckedIOException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateFileSystemLoopException
import java.io.UncheckedIOException; //导入依赖的package包/类
private void validateFileSystemLoopException(Path start, Path... causes) {
try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
try {
int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
fail("Should got FileSystemLoopException, but got " + count + "elements.");
} catch (UncheckedIOException uioe) {
IOException ioe = uioe.getCause();
if (ioe instanceof FileSystemLoopException) {
FileSystemLoopException fsle = (FileSystemLoopException) ioe;
boolean match = false;
for (Path cause: causes) {
if (fsle.getFile().equals(cause.toString())) {
match = true;
break;
}
}
assertTrue(match);
} else {
fail("Unexpected UncheckedIOException cause " + ioe.toString());
}
}
} catch(IOException ex) {
fail("Unexpected IOException " + ex);
}
}
示例2: doBackward
import java.io.UncheckedIOException; //导入依赖的package包/类
@Override
protected com.linecorp.centraldogma.common.Entry<?> doBackward(Entry entry) {
switch (entry.getType()) {
case JSON:
try {
JsonNode value = Jackson.readTree(entry.getContent());
return com.linecorp.centraldogma.common.Entry.ofJson(entry.getPath(), value);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
case TEXT:
return com.linecorp.centraldogma.common.Entry.ofText(entry.getPath(), entry.getContent());
case DIRECTORY:
return com.linecorp.centraldogma.common.Entry.ofDirectory(entry.getPath());
default:
throw new IllegalArgumentException("unsupported entry type: " + entry.getType());
}
}
示例3: createStatus
import java.io.UncheckedIOException; //导入依赖的package包/类
@Whitelisted
public CommitStatusGroovyObject createStatus(final String status,
final String context,
final String description,
final String targetUrl) {
Objects.requireNonNull(status, "status is a required argument");
CommitStatus commitStatus = new CommitStatus();
commitStatus.setState(status);
commitStatus.setContext(context);
commitStatus.setDescription(description);
commitStatus.setTargetUrl(targetUrl);
try {
return new CommitStatusGroovyObject(
commitService.createStatus(base, commit.getSha(), commitStatus));
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
}
示例4: getContent
import java.io.UncheckedIOException; //导入依赖的package包/类
@Override
public Iterable<String> getContent(String path) {
String[] parts = path.split("/");
path = parts[parts.length-1]
.replace('?', '-')
.replace('&', '-')
.replace('=', '-')
.replace(',', '-')
.substring(0,68);
try {
InputStream in = ClassLoader.getSystemResource(path).openStream();
/*
* Consumir o Inputstream e adicionar dados ao res
*/
Iterator<String> iter = new IteratorFromReader(in);
return () -> iter;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例5: readClassAsEntry
import java.io.UncheckedIOException; //导入依赖的package包/类
private static Map<String, Set<String>> readClassAsEntry(InputStream input) {
HashMap<String, Set<String>> map = new HashMap<>();
try {
ClassReader reader = new ClassReader(input);
String className = reader.getClassName().replace('/', '.');
reader.accept(new ClassVisitor(Opcodes.ASM6) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
String methodName = className + '.' + name;
map.computeIfAbsent(methodName, __ -> new HashSet<>()).add(methodName + desc);
return null;
}
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG);
} catch(IOException e) {
throw new UncheckedIOException(e);
}
return map;
}
示例6: mapToNakadiEvent
import java.io.UncheckedIOException; //导入依赖的package包/类
public NakadiEvent mapToNakadiEvent(final EventLog event) {
final NakadiEvent nakadiEvent = new NakadiEvent();
final NakadiMetadata metadata = new NakadiMetadata();
metadata.setEid(convertToUUID(event.getId()));
metadata.setOccuredAt(event.getCreated());
metadata.setFlowId(event.getFlowId());
nakadiEvent.setMetadata(metadata);
HashMap<String, Object> payloadDTO;
try {
payloadDTO = objectMapper.readValue(event.getEventBodyData(), new TypeReference<LinkedHashMap<String, Object>>() { });
} catch (IOException e) {
log.error("An error occurred at JSON deserialization", e);
throw new UncheckedIOException(e);
}
nakadiEvent.setData(payloadDTO);
return nakadiEvent;
}
开发者ID:zalando-nakadi,项目名称:nakadi-producer-spring-boot-starter,代码行数:22,代码来源:EventTransmissionService.java
示例7: getBundle
import java.io.UncheckedIOException; //导入依赖的package包/类
/**
* Returns a {@code ResourceBundle} for the given {@code baseName} and
* {@code locale}.
*
* @implNote
* The default implementation of this method calls the
* {@link #toBundleName(String, Locale) toBundleName} method to get the
* bundle name for the {@code baseName} and {@code locale} and finds the
* resource bundle of the bundle name local in the module of this provider.
* It will only search the formats specified when this provider was
* constructed.
*
* @param baseName the base bundle name of the resource bundle, a fully
* qualified class name.
* @param locale the locale for which the resource bundle should be instantiated
* @return {@code ResourceBundle} of the given {@code baseName} and
* {@code locale}, or {@code null} if no resource bundle is found
* @throws NullPointerException if {@code baseName} or {@code locale} is
* {@code null}
* @throws UncheckedIOException if any IO exception occurred during resource
* bundle loading
*/
@Override
public ResourceBundle getBundle(String baseName, Locale locale) {
Module module = this.getClass().getModule();
String bundleName = toBundleName(baseName, locale);
ResourceBundle bundle = null;
for (String format : formats) {
try {
if (FORMAT_CLASS.equals(format)) {
bundle = loadResourceBundle(module, bundleName);
} else if (FORMAT_PROPERTIES.equals(format)) {
bundle = loadPropertyResourceBundle(module, bundleName);
}
if (bundle != null) {
break;
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
return bundle;
}
示例8: cancel
import java.io.UncheckedIOException; //导入依赖的package包/类
public void cancel(IOException cause) {
// If the impl is non null, propagate the exception right away.
// Otherwise record it so that it can be propagated once the
// exchange impl has been established.
ExchangeImpl<?> impl = exchImpl;
if (impl != null) {
// propagate the exception to the impl
impl.cancel(cause);
} else {
try {
// no impl yet. record the exception
failed = cause;
// now call checkCancelled to recheck the impl.
// if the failed state is set and the impl is not null, reset
// the failed state and propagate the exception to the impl.
checkCancelled(false);
} catch (IOException x) {
// should not happen - we passed 'false' above
throw new UncheckedIOException(x);
}
}
}
示例9: getResourceAsString
import java.io.UncheckedIOException; //导入依赖的package包/类
private static String getResourceAsString(final String resourceName)
{
final StringBuilder stringBuilder = new StringBuilder();
final InputStream resourceAsStream = ClassLoader.getSystemClassLoader().getResourceAsStream(resourceName);
try
{
int read;
while ((read = resourceAsStream.read()) != -1)
{
final char aByte = (char)read;
stringBuilder.append(aByte);
}
}
catch (final IOException e)
{
throw new UncheckedIOException(e);
}
return stringBuilder.toString();
}
示例10: acceptClassComment
import java.io.UncheckedIOException; //导入依赖的package包/类
@Override
public void acceptClassComment(String srcName, String comment) {
try {
switch (format) {
case TINY:
case TINY_GZIP:
writer.write("CLS-CMT\t");
writer.write(srcName);
writer.write('\t');
writer.write(escape(comment));
writer.write('\n');
break;
case SRG:
// not supported
break;
case ENIGMA:
enigmaState.acceptClassComment(srcName, comment);
break;
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例11: resources
import java.io.UncheckedIOException; //导入依赖的package包/类
@Override
public Stream<URL> resources(String name) {
Objects.requireNonNull(name);
// ordering not specified
int characteristics = (Spliterator.NONNULL | Spliterator.IMMUTABLE |
Spliterator.SIZED | Spliterator.SUBSIZED);
Supplier<Spliterator<URL>> supplier = () -> {
try {
List<URL> urls = findResourcesAsList(name);
return Spliterators.spliterator(urls, characteristics);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
};
Stream<URL> s1 = StreamSupport.stream(supplier, characteristics, false);
Stream<URL> s2 = parent.resources(name);
return Stream.concat(s1, s2);
}
示例12: read
import java.io.UncheckedIOException; //导入依赖的package包/类
public static CompiledScene read(final Camera camera, final DataInputStream dataInputStream) {
try {
final String name = dataInputStream.readUTF();
final float[] boundingVolumeHierarchy = doReadFloatArray(dataInputStream);
final float[] cameraArray = doReadFloatArray(dataInputStream, camera.getArray());
final float[] point2s = doReadFloatArray(dataInputStream);
final float[] point3s = doReadFloatArray(dataInputStream);
final float[] shapes = doReadFloatArray(dataInputStream);
final float[] surfaces = doReadFloatArray(dataInputStream);
final float[] textures = doReadFloatArray(dataInputStream);
final float[] vector3s = doReadFloatArray(dataInputStream);
final int[] shapeOffsets = doReadIntArray(dataInputStream);
return new CompiledScene(boundingVolumeHierarchy, cameraArray, point2s, point3s, shapes, surfaces, textures, vector3s, shapeOffsets, name);
} catch(final IOException e) {
throw new UncheckedIOException(e);
}
}
示例13: write
import java.io.UncheckedIOException; //导入依赖的package包/类
public void write(final DataOutputStream dataOutputStream) {
try {
dataOutputStream.writeUTF(this.name);
doWriteFloatArray(dataOutputStream, this.boundingVolumeHierarchy);
doWriteFloatArray(dataOutputStream, this.camera);
doWriteFloatArray(dataOutputStream, this.point2s);
doWriteFloatArray(dataOutputStream, this.point3s);
doWriteFloatArray(dataOutputStream, this.shapes);
doWriteFloatArray(dataOutputStream, this.surfaces);
doWriteFloatArray(dataOutputStream, this.textures);
doWriteFloatArray(dataOutputStream, this.vector3s);
doWriteIntArray(dataOutputStream, this.shapeOffsets);
} catch(final IOException e) {
throw new UncheckedIOException(e);
}
}
示例14: readRequest
import java.io.UncheckedIOException; //导入依赖的package包/类
private boolean readRequest(SocketChannel channel, StringBuilder request)
throws IOException
{
ByteBuffer buffer = ByteBuffer.allocate(512);
int num = channel.read(buffer);
if (num == -1) {
return false;
}
CharBuffer decoded;
buffer.flip();
try {
decoded = ISO_8859_1.newDecoder().decode(buffer);
} catch (CharacterCodingException e) {
throw new UncheckedIOException(e);
}
request.append(decoded);
return Pattern.compile("\r\n\r\n").matcher(request).find();
}
示例15: copyOwnResources
import java.io.UncheckedIOException; //导入依赖的package包/类
/**
* Copies the resources from the specified module that affects itself. Resources that affect dependencies of the
* specified module are not copied.
*/
private void copyOwnResources(List<CarnotzetModule> processedModules, CarnotzetModule module) throws IOException {
Path expandedJarPath = expandedJars.resolve(module.getName());
Path resolvedModulePath = resolved.resolve(module.getServiceId());
if (!resolvedModulePath.toFile().exists() && !resolvedModulePath.toFile().mkdirs()) {
throw new CarnotzetDefinitionException("Could not create directory " + resolvedModulePath);
}
// copy all regular files at the root of the expanded jar (such as carnotzet.properties)
// copy all directories that do not reconfigure another module from the expanded jar recursively
Files.find(expandedJarPath, 1, isRegularFile().or(nameMatchesModule(processedModules).negate()))
.forEach(source -> {
try {
if (Files.isRegularFile(source)) {
Files.copy(source, resolvedModulePath.resolve(source.getFileName()), StandardCopyOption.REPLACE_EXISTING);
} else if (Files.isDirectory(source)) {
FileUtils.copyDirectory(source.toFile(), resolvedModulePath.resolve(source.getFileName()).toFile());
}
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
});
}