Java 类java.io.IOError 实例源码

项目:sstable-adaptor    文件:UnfilteredRowIteratorSerializer.java   
public UnfilteredRowIterator deserialize(DataInputPlus in, int version, CFMetaData metadata, SerializationHelper.Flag flag, Header header) throws IOException
{
    if (header.isEmpty)
        return EmptyIterators.unfilteredRow(metadata, header.key, header.isReversed);

    final SerializationHelper helper = new SerializationHelper(metadata, version, flag);
    final SerializationHeader sHeader = header.sHeader;
    return new AbstractUnfilteredRowIterator(metadata, header.key, header.partitionDeletion, sHeader.columns(), header.staticRow, header.isReversed, sHeader.stats())
    {
        private final Row.Builder builder = BTreeRow.sortedBuilder();

        protected Unfiltered computeNext()
        {
            try
            {
                Unfiltered unfiltered = UnfilteredSerializer.serializer.deserialize(in, sHeader, helper, builder);
                return unfiltered == null ? endOfData() : unfiltered;
            }
            catch (IOException e)
            {
                throw new IOError(e);
            }
        }
    };
}
项目:sstable-adaptor    文件:SSTableSimpleIterator.java   
protected Unfiltered computeNext()
{
    while (true)
    {
        try
        {
            if (!deserializer.hasNext())
                return endOfData();

            Unfiltered unfiltered = deserializer.readNext();
            if (metadata.isStaticCompactTable() && unfiltered.kind() == Unfiltered.Kind.ROW)
            {
                Row row = (Row) unfiltered;
                ColumnDefinition def = metadata.getColumnDefinition(LegacyLayout.encodeClustering(metadata, row.clustering()));
                if (def != null && def.isStatic())
                    continue;
            }
            return unfiltered;
        }
        catch (IOException e)
        {
            throw new IOError(e);
        }
    }
}
项目:elasticsearch_my    文件:ElasticsearchUncaughtExceptionHandler.java   
@Override
public void uncaughtException(Thread t, Throwable e) {
    if (isFatalUncaught(e)) {
        try {
            onFatalUncaught(t.getName(), e);
        } finally {
            // we use specific error codes in case the above notification failed, at least we
            // will have some indication of the error bringing us down
            if (e instanceof InternalError) {
                halt(128);
            } else if (e instanceof OutOfMemoryError) {
                halt(127);
            } else if (e instanceof StackOverflowError) {
                halt(126);
            } else if (e instanceof UnknownError) {
                halt(125);
            } else if (e instanceof IOError) {
                halt(124);
            } else {
                halt(1);
            }
        }
    } else {
        onNonFatalUncaught(t.getName(), e);
    }
}
项目:centraldogma    文件:CentralDogmaSecurityManager.java   
public CentralDogmaSecurityManager(File dataDir, Ini securityConfig) {
    try {
        sessionDao = new FileBasedSessionDAO(new File(dataDir, "_sessions").toPath());
    } catch (IOException e) {
        throw new IOError(e);
    }

    sessionManager = new CentralDogmaSessionManager(sessionDao);
    final Factory<SecurityManager> factory = new IniSecurityManagerFactory(securityConfig) {
        @Override
        protected SecurityManager createDefaultInstance() {
            DefaultSecurityManager securityManager = new DefaultSecurityManager();
            securityManager.setSessionManager(sessionManager);
            securityManager.setCacheManager(new MemoryConstrainedCacheManager());
            return securityManager;
        }
    };
    delegate = factory.getInstance();
}
项目:mochalog    文件:SandboxedPrologContext.java   
/**
 * Constructor.
 * @param module Working module
 */
public SandboxedPrologContext(Module module) throws IOError
{
    this.workingModule = module;

    // Load the Mochalog Prolog bridge API into the given
    // Prolog context
    try
    {
        // Ignore output from pack_install routine
        // TODO: Remove need to force re-upgrade (currently in place due to error logging
        prove("pack_install('@A', [interactive(false), silent(true), upgrade(true)])",
            PackLoader.getPackResource("mochalog"));
        // Build against Mochalog API module
        prove("use_module(library(mochalog))");
    }
    catch (IOException e)
    {
        throw new IOError(e);
    }
}
项目:mochalog    文件:PathUtils.java   
/**
 * Convert unvalidated path object to fully validated
 * path string.
 * @param path Unvalidated file path
 * @return Validated path string
 * @throws IOException IO error occurred.
 */
public static String getResolvableFilePath(Path path) throws IOException
{
    // Ensure valid file path was supplied
    if (!Files.exists(path))
    {
        throw new IOException("Specified file path could not be resolved");
    }

    try
    {
        // Convert to absolute path with forward-slash file
        // separators
        Path absolutePath = path.toAbsolutePath();
        return absolutePath.toString().replace('\\', '/');
    }
    catch (IOError e)
    {
        throw new IOException("File path could not be converted " +
            "to absolute file path.");
    }
}
项目:openjdk-jdk10    文件:Source.java   
/**
 * Returns the base directory or URL for the given URL. Used to implement __DIR__.
 * @param url a URL
 * @return base path or URL, or null if argument is not a hierarchical URL
 */
public static String baseURL(final URL url) {
    try {
        final URI uri = url.toURI();

        if (uri.getScheme().equals("file")) {
            final Path path = Paths.get(uri);
            final Path parent = path.getParent();
            return (parent != null) ? (parent + File.separator) : null;
        }
        if (uri.isOpaque() || uri.getPath() == null || uri.getPath().isEmpty()) {
            return null;
        }
        return uri.resolve("").toString();

    } catch (final SecurityException | URISyntaxException | IOError e) {
        return null;
    }
}
项目:docforia    文件:JsonCoreWriter.java   
@Override
public void write(PropertyMap propertyMap) {
    try {
        jsonWriter.writeStartObject();
        jsonWriter.writeObjectFieldStart("prop");
        jsonWriter.writeStartObject();
        for (String s : propertyMap.properties.keySet()) {
            jsonWriter.writeObjectFieldStart(s);

            DataRef ref = propertyMap.properties.get(s);
            if(ref instanceof CoreRef) {
                ((CoreRef) ref).write(this);
            } else {
                throw new UnsupportedOperationException("Only core properties are supported with PropertyMap!");
            }
        }
        jsonWriter.writeEndObject();
        jsonWriter.writeEndObject();
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:docforia    文件:JsonCoreWriter.java   
@Override
public void writeIntArray(int[] intValues) {
    try {
        jsonWriter.writeStartObject();
        jsonWriter.writeArrayFieldStart("intarray");

        for (int value : intValues) {
            jsonWriter.writeNumber(value);
        }

        jsonWriter.writeEndArray();
        jsonWriter.writeEndObject();
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:docforia    文件:JsonCoreWriter.java   
@Override
public void writeLongArray(long[] longValues) {
    try {
        jsonWriter.writeStartObject();
        jsonWriter.writeArrayFieldStart("longarray");

        for (long value : longValues) {
            jsonWriter.writeNumber(value);
        }

        jsonWriter.writeEndArray();
        jsonWriter.writeEndObject();
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:docforia    文件:JsonCoreWriter.java   
@Override
public void writeDocumentArray(MemoryDocument[] docValues) {
    try {
        jsonWriter.writeStartObject();
        jsonWriter.writeObjectFieldStart("docarray");

        jsonWriter.writeStartArray(docValues.length);
        for (MemoryDocument document : docValues) {
            MemoryJsonLevel0Codec.INSTANCE.encode(document, jsonWriter);
        }
        jsonWriter.writeEndArray();

        jsonWriter.writeEndObject();
        jsonWriter.writeEndObject();
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:docforia    文件:MemoryJsonLevel0Codec.java   
public void writeProperties(Object2ObjectOpenHashMap<String,DataRef> props) {
    try {
        writer.writeStartObject();
        for (Object2ObjectMap.Entry<String, DataRef> entry : props.object2ObjectEntrySet()) {
            writer.writeFieldName(entry.getKey());
            if(entry.getValue() instanceof CoreRef) {
                CoreRef prop =  (CoreRef)(entry.getValue());
                prop.write(propwriter);
            }
            else
                throw new UnsupportedOperationException("Only CoreRefs are supported for encoding.");
        }

        writer.writeEndObject();
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:docforia    文件:MemoryBinaryV1L2Codec.java   
private PropertySet[] readPropertySets(PropertyKey[] keys, Int2ObjectOpenHashMap<IntArrayList> pkeyid2setid) {
    int numPropertySets = reader.readVarInt(true);
    if(numPropertySets < 0)
        throw new IOError(new IOException("Failed to read property sets, count is negative: " + numPropertySets));

    PropertySet[] propertySets = new PropertySet[numPropertySets];

    for(int i = 0; i < numPropertySets; i++) {
        int numKeys = reader.readVarInt(true);
        PropertyKey[] propertySet = new PropertyKey[numKeys];
        for(int k = 0; k < numKeys; k++) {
            int pkey;
            propertySet[k] = keys[pkey = reader.readVarInt(true)];
            getPkey2IdList(pkeyid2setid, pkey).add(i);
        }

        propertySets[i] = new PropertySet(propertySet);
    }

    return propertySets;
}
项目:docforia    文件:Output.java   
/** @return true if the buffer has been resized. */
protected boolean require (int required) {
    if (capacity - position >= required) return false;
    if (required > maxCapacity)
        throw new IOError(new IOException("Buffer overflow. Max capacity: " + maxCapacity + ", required: " + required));
    flush();
    while (capacity - position < required) {
        if (capacity == maxCapacity)
            throw new IOError(new IOException("Buffer overflow. Available: " + (capacity - position) + ", required: " + required));
        // Grow buffer.
        if (capacity == 0) capacity = 1;
        capacity = Math.min(capacity * 2, maxCapacity);
        if (capacity < 0) capacity = maxCapacity;
        byte[] newBuffer = new byte[capacity];
        System.arraycopy(buffer, 0, newBuffer, 0, position);
        buffer = newBuffer;
    }
    return true;
}
项目:docforia    文件:GzipUtil.java   
public static byte[] compress(byte[] data) {
    try {
        //Heuristic, 75% compression.
        Output compressed = new Output(32,2147483647);
        GZIPOutputStream gzipOutputStream = new GZIPOutputStream(compressed, 1 << 12);

        Output output = new Output(gzipOutputStream);
        output.writeVarInt(data.length, true);
        output.write(data);
        output.close();

        return compressed.toBytes();
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:docforia    文件:GzipUtil.java   
public static ByteBuffer compress(ByteBuffer data) {
    try {
        //Heuristic, 75% compression.
        ByteBufferOutputStream bufferOutputStream = new ByteBufferOutputStream();
        GZIPOutputStream gzipOutputStream = new GZIPOutputStream(bufferOutputStream, 1 << 12);

        Output output = new Output(gzipOutputStream);
        output.writeVarInt(data.remaining(), true);
        output.write(data);
        output.close();

        ByteBuffer buffer = bufferOutputStream.buffer();
        buffer.flip();
        return buffer;
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:langforia    文件:AnchorLookup.java   
@Inject
public AnchorLookup(@Model(MODEL) Resource resource, @LanguageCode String language) {
    try {
        this.language = language;
        System.out.println("Loading anchor lookup map for " + language);
        BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(resource.binaryRead())));
        String line = null;
        while((line = reader.readLine()) != null) {
            String[] split = line.split("\t", 2);
            String source = split[0];
            String target = split[1];
            lookup.put(source, target);
        }
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:langforia    文件:SimpleWordSet.java   
@Inject
public SimpleWordSet(@Model(MODEL_ID) Resource resource) {
    BufferedReader reader = new BufferedReader(resource.textRead());
    String line;

    try {
        while( (line = reader.readLine()) != null) {
            String trimmed = line.trim();
            if(trimmed.length() == 0)
                continue;

            words.add(trimmed);
        }
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:cassandra-kmean    文件:AbstractCell.java   
public static Iterator<OnDiskAtom> onDiskIterator(final DataInput in,
                                                  final ColumnSerializer.Flag flag,
                                                  final int expireBefore,
                                                  final Descriptor.Version version,
                                                  final CellNameType type)
{
    return new AbstractIterator<OnDiskAtom>()
    {
        protected OnDiskAtom computeNext()
        {
            OnDiskAtom atom;
            try
            {
                atom = type.onDiskAtomSerializer().deserializeFromSSTable(in, flag, expireBefore, version);
            }
            catch (IOException e)
            {
                throw new IOError(e);
            }
            if (atom == null)
                return endOfData();

            return atom;
        }
    };
}
项目:cassandra-kmean    文件:NodeTool.java   
private static void printHistory(String... args)
{
    //don't bother to print if no args passed (meaning, nodetool is just printing out the sub-commands list)
    if (args.length == 0)
        return;

    String cmdLine = Joiner.on(" ").skipNulls().join(args);
    cmdLine = cmdLine.replaceFirst("(?<=(-pw|--password))\\s+\\S+", " <hidden>");

    try (FileWriter writer = new FileWriter(new File(FBUtilities.getToolsOutputDirectory(), HISTORYFILE), true))
    {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
        writer.append(sdf.format(new Date())).append(": ").append(cmdLine).append(System.lineSeparator());
    }
    catch (IOException | IOError ioe)
    {
        //quietly ignore any errors about not being able to write out history
    }
}
项目:cassandra-kmean    文件:DataIntegrityMetadata.java   
public void append(byte[] buffer, int start, int end, boolean checksumIncrementalResult)
{
    try
    {
        int incrementalChecksumValue;

        incrementalChecksum.update(buffer, start, end);
        incrementalChecksumValue = (int) incrementalChecksum.getValue();
        incrementalOut.writeInt(incrementalChecksumValue);
        incrementalChecksum.reset();

        fullChecksum.update(buffer, start, end);

        if (checksumIncrementalResult)
        {
            ByteBuffer byteBuffer = ByteBuffer.allocate(4);
            byteBuffer.putInt(incrementalChecksumValue);
            fullChecksum.update(byteBuffer.array(), 0, byteBuffer.array().length);
        }
    }
    catch (IOException e)
    {
        throw new IOError(e);
    }
}
项目:cassandra-kmean    文件:StressProfile.java   
public static StressProfile load(URI file) throws IOError
{
    try
    {
        Constructor constructor = new Constructor(StressYaml.class);

        Yaml yaml = new Yaml(constructor);

        InputStream yamlStream = file.toURL().openStream();

        if (yamlStream.available() == 0)
            throw new IOException("Unable to load yaml file from: "+file);

        StressYaml profileYaml = yaml.loadAs(yamlStream, StressYaml.class);

        StressProfile profile = new StressProfile();
        profile.init(profileYaml);

        return profile;
    }
    catch (YAMLException | IOException | RequestValidationException e)
    {
        throw new IOError(e);
    }
}
项目:gtfs-lib    文件:GTFSFeed.java   
private static DB constructDB(String dbFile) {
        DB db;
        try{
            DBMaker dbMaker = DBMaker.newFileDB(new File(dbFile));
            db = dbMaker
                    .transactionDisable()
                    .mmapFileEnable()
                    .asyncWriteEnable()
                    .compressionEnable()
//                     .cacheSize(1024 * 1024) this bloats memory consumption
                    .make();
            return db;
        } catch (ExecutionError | IOError | Exception e) {
            LOG.error("Could not construct db from file.", e);
            return null;
        }
    }
项目:aspectran    文件:DefaultConsole.java   
@Override
public String readLine(String prompt) {
    try {
        if (System.console() != null) {
            return System.console().readLine(prompt);
        } else {
            if (prompt != null) {
                write(prompt);
            }
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            return reader.readLine();
        }
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:AppWoksUtils    文件:IDEConsole.java   
public String readLine(String fmt, Object... args) {
    String line = null;
    synchronized (this.writeLock) {
        synchronized (this.readLock) {
            if (fmt.length() != 0) {
                this.writer.format(fmt, args);
            }
            try {
                char[] ca = this.readline(false);
                if (ca != null) {
                    line = new String(ca);
                }
            } catch (IOException x) {
                throw new IOError(x);
            }
        }
    }
    return line;
}
项目:pasteque-android    文件:Transaction.java   
@Override
public void onCustomerPicked(Customer customer) {
    TicketFragment tFrag = getTicketFragment();
    tFrag.setCustomer(customer);
    tFrag.updateView();
    if (mPager.getCurrentItem() != CATALOG_FRAG) {
        updatePaymentFragment(tFrag, null);
    }
    disposeTicketFragment(tFrag);
    try {
        Data.Session.save(mContext);
    } catch (IOError ioe) {
        Log.e(LOG_TAG, "Unable to save session", ioe);
        Error.showError(R.string.err_save_session, this);
    }
}
项目:pasteque-android    文件:CloseCash.java   
private void closeCashAction() throws IOException {
    Data.Cash.currentCash(this).closeNow();
    Data.Cash.dirty = true;
    // Archive and create a new cash
    CashArchive.archiveCurrent();
    Data.Cash.clear(this);
    int cashRegId = Data.CashRegister.current(this).getId();
    Data.Cash.setCash(new Cash(cashRegId));
    Data.Receipt.clear(this);
    try {
        Data.Cash.save(this);
    } catch (IOError e) {
        Log.e(LOG_TAG, "Unable to save cash", e);
        Error.showError(R.string.err_save_cash, this);
    }
    Data.Session.clear(this);
}
项目:pasteque-android    文件:CloseCash.java   
/**
 * On check result
 */
@Override
protected void onActivityResult(int requestCode, int resultCode,
                                Intent data) {
    switch (resultCode) {
        case Activity.RESULT_CANCELED:
            // Check canceled, undo close
            this.undoClose();
            break;
        case Activity.RESULT_OK:
            if (data.hasExtra("inventory")) {
                Inventory inv = (Inventory) data.getSerializableExtra("inventory");
                Data.Cash.currentCash(this).setCloseInventory(inv);
                try {
                    Data.Cash.save(this);
                } catch (IOError e) {
                    Log.e(LOG_TAG, "Unable to save cash", e);
                    Error.showError(R.string.err_save_cash, this);
                }
            }
            // Continue close process
            this.closeCash();
            break;
    }
}
项目:pasteque-android    文件:AbstractJsonDataSavable.java   
@Override
public void load(Context ctx) throws DataCorruptedException, IOError {
    int objectsNumber = getNumberOfObjects();
    List<Type> classes = getClassList();
    List<Object> result = new ArrayList<>();
    Gson gson = getGson();
    JsonParser parser = new JsonParser();
    String stringFile = null;
    try {
        stringFile = file.read();
        JsonElement tradeElement = parser.parse(stringFile);
        JsonArray array = tradeElement.getAsJsonArray();
        for (int i = 0; i < objectsNumber; i++) {
            Object objectToAdd = gson.fromJson(gson.toJson(array.get(i)), classes.get(i));
            result.add(i, objectToAdd);
        }
    } catch (JsonSyntaxException | FileNotFoundException | IllegalStateException e) {
        throw newException(e, stringFile);
    }
    if (result.size() != getObjectList().size()) {
        throw newException(null, stringFile);
    }
    this.recoverObjects(result);
}
项目:traceability-assistant    文件:LSA.java   
protected SemanticSpace getSpace() {
    try {
        int dimensions = argOptions.getIntOption("dimensions", 300);
        Transform transform = new LogEntropyTransform();
        if (argOptions.hasOption("preprocess"))
            transform = ReflectionUtil.getObjectInstance(
                    argOptions.getStringOption("preprocess"));
        String algName = argOptions.getStringOption("svdAlgorithm", "ANY");
        MatrixFactorization factorization = SVD.getFactorization(
                Algorithm.valueOf(algName.toUpperCase()));
        basis = new StringBasisMapping();

        return new LatentSemanticAnalysis(
            false, dimensions, transform, factorization, false, basis);
    } catch (IOException ioe) {
        throw new IOError(ioe);
    }
}
项目:asakusafw-compiler    文件:FileEditor.java   
/**
 * Extracts entries into the directory.
 * @param source the source archive file
 * @param destination the destination file
 */
public static void extract(File source, File destination) {
    try (ZipInputStream input = new ZipInputStream(open(source))) {
        while (true) {
            ZipEntry entry = input.getNextEntry();
            if (entry == null) {
                break;
            }
            File target = new File(destination, entry.getName());
            if (entry.isDirectory()) {
                mkdir(target);
            } else {
                copy(input, target);
            }
        }
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:asakusafw-compiler    文件:FileEditor.java   
/**
 * Extracts entries into the directory.
 * @param source the source archive input stream
 * @param destination the destination file
 */
public static void extract(ZipInputStream source, File destination) {
    try {
        while (true) {
            ZipEntry entry = source.getNextEntry();
            if (entry == null) {
                break;
            }
            File target = new File(destination, entry.getName());
            if (entry.isDirectory()) {
                mkdir(target);
            } else {
                copy(source, target);
            }
        }
    } catch (IOException e) {
        throw new IOError(e);
    }
}
项目:scylla-tools-java    文件:UnfilteredRowIteratorSerializer.java   
public UnfilteredRowIterator deserialize(DataInputPlus in, int version, CFMetaData metadata, SerializationHelper.Flag flag, Header header) throws IOException
{
    if (header.isEmpty)
        return EmptyIterators.unfilteredRow(metadata, header.key, header.isReversed);

    final SerializationHelper helper = new SerializationHelper(metadata, version, flag);
    final SerializationHeader sHeader = header.sHeader;
    return new AbstractUnfilteredRowIterator(metadata, header.key, header.partitionDeletion, sHeader.columns(), header.staticRow, header.isReversed, sHeader.stats())
    {
        private final Row.Builder builder = BTreeRow.sortedBuilder();

        protected Unfiltered computeNext()
        {
            try
            {
                Unfiltered unfiltered = UnfilteredSerializer.serializer.deserialize(in, sHeader, helper, builder);
                return unfiltered == null ? endOfData() : unfiltered;
            }
            catch (IOException e)
            {
                throw new IOError(e);
            }
        }
    };
}
项目:scylla-tools-java    文件:SSTableSimpleIterator.java   
protected Unfiltered computeNext()
{
    try
    {
        if (!deserializer.hasNext())
            return endOfData();

        Unfiltered unfiltered = deserializer.readNext();
        if (metadata.isStaticCompactTable() && unfiltered.kind() == Unfiltered.Kind.ROW)
        {
            Row row = (Row) unfiltered;
            ColumnDefinition def = metadata.getColumnDefinition(LegacyLayout.encodeClustering(metadata, row.clustering()));
            if (def != null && def.isStatic())
                return computeNext();
        }
        return unfiltered;
    }
    catch (IOException e)
    {
        throw new IOError(e);
    }
}
项目:scylla-tools-java    文件:StressProfile.java   
public static StressProfile load(URI file) throws IOError
{
    try
    {
        Constructor constructor = new Constructor(StressYaml.class);

        Yaml yaml = new Yaml(constructor);

        InputStream yamlStream = file.toURL().openStream();

        if (yamlStream.available() == 0)
            throw new IOException("Unable to load yaml file from: "+file);

        StressYaml profileYaml = yaml.loadAs(yamlStream, StressYaml.class);

        StressProfile profile = new StressProfile();
        profile.init(profileYaml);

        return profile;
    }
    catch (YAMLException | IOException | RequestValidationException e)
    {
        throw new IOError(e);
    }
}
项目:scylla-tools-java    文件:Util.java   
public static Closeable markDirectoriesUnwriteable(ColumnFamilyStore cfs)
{
    try
    {
        for ( ; ; )
        {
            DataDirectory dir = cfs.getDirectories().getWriteableLocation(1);
            BlacklistedDirectories.maybeMarkUnwritable(cfs.getDirectories().getLocationForDisk(dir));
        }
    }
    catch (IOError e)
    {
        // Expected -- marked all directories as unwritable
    }
    return () -> BlacklistedDirectories.clearUnwritableUnsafe();
}
项目:scylla-tools-java    文件:LogTransactionTest.java   
static Set<File> listFiles(File folder, Directories.FileType... types)
{
    Collection<Directories.FileType> match = Arrays.asList(types);
    return new LogAwareFileLister(folder.toPath(),
                                  (file, type) -> match.contains(type),
                                  Directories.OnTxnErr.IGNORE).list()
                   .stream()
                   .map(f -> {
                       try
                       {
                           return f.getCanonicalFile();
                       }
                       catch (IOException e)
                       {
                           throw new IOError(e);
                       }
                   })
                   .collect(Collectors.toSet());
}
项目:bigdata-interop    文件:ApiErrorExtractorTest.java   
/**
 * Validates ioError().
 */
@Test
public void testIOError() {
  // Check true cases.
  Throwable ioError1 = new EOFException("io error 1");
  assertTrue(errorExtractor.ioError(ioError1));
  assertTrue(errorExtractor.ioError(new Exception(ioError1)));
  assertTrue(errorExtractor.ioError(new RuntimeException(new RuntimeException(ioError1))));

  Throwable ioError2 = new IOException("io error 2");
  assertTrue(errorExtractor.ioError(ioError2));
  assertTrue(errorExtractor.ioError(new Exception(ioError2)));
  assertTrue(errorExtractor.ioError(new RuntimeException(new RuntimeException(ioError2))));

  Throwable ioError3 = new IOError(new Exception("io error 3"));
  assertTrue(errorExtractor.ioError(ioError3));
  assertTrue(errorExtractor.ioError(new Exception(ioError3)));
  assertTrue(errorExtractor.ioError(new RuntimeException(new RuntimeException(ioError3))));

  // Check false cases.
  Throwable notIOError = new Exception("not io error");
  assertFalse(errorExtractor.ioError(notIOError));
  assertFalse(errorExtractor.ioError(new RuntimeException(notIOError)));
}
项目:omise-android    文件:CreditCardActivity.java   
@Override
public void onTokenRequestFailed(TokenRequest request, Throwable throwable) {
    enableForm();

    TextView textView = views.textView(R.id.text_error_message);
    textView.setVisibility(View.VISIBLE);

    String message = null;
    if (throwable instanceof IOError) {
        message = getString(R.string.error_io, throwable.getMessage());
    } else if (throwable instanceof APIError) {
        message = getString(R.string.error_api, ((APIError) throwable).message);
    } else {
        message = getString(R.string.error_unknown, throwable.getMessage());
    }

    textView.setText(message);
}
项目:wikiforia    文件:PlainTextWikipediaPageWriter.java   
@Override
public synchronized void process(List<WikipediaPage> batch) {
    if(this.fileChannel == null)
        return;

    try {
        if(batch.size() == 0) {
            this.fileChannel.write(ByteBuffer.wrap("\n".getBytes("utf-8")));
            this.fileChannel.close();
            this.fileChannel = null;
            return;
        }

        for (WikipediaPage wikipediaPage : batch) {
            if(wikipediaPage.getText().length() > 0) {
                this.fileChannel.write(ByteBuffer.wrap(wikipediaPage.getText().getBytes("utf-8")));
                this.fileChannel.write(ByteBuffer.wrap("\n".getBytes("utf-8")));
            }
        }
    } catch (IOException e) {
        throw new IOError(e);
    }
}