Java URI Create getURIStream(Object obj)

Here you can find the source of getURIStream(Object obj)

Description

get URI Stream

License

Open Source License

Declaration

public static InputStream getURIStream(Object obj) throws IOException 

Method Source Code

//package com.java2s;
/*************************************************************************
 * Copyright (c) 2012 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/* w w  w.j  ava2  s  .c o m*/
 *  Actuate Corporation - added support of relative file path
 *  Actuate Corporation - support defining an Excel input file path or URI as part of the data source definition
 *************************************************************************
 */

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;

public class Main {
    public static InputStream getURIStream(Object obj) throws IOException {
        if (obj instanceof File) {
            return new BufferedInputStream(new FileInputStream((File) obj));
        }

        else if (obj instanceof URI) {
            return ((URI) obj).toURL().openStream();
        }

        return null;
    }
}

Related

  1. getURIName(URI uri)
  2. getURIParameterValue(URI uri, String name, String defVal)
  3. getURIs(final Object[] objs)
  4. getUriScheme(String address)
  5. getURIsPrettyPrint(final Collection uris)
  6. getURIWithAuthority(URI uri, String authority)
  7. stringToUri(String fileString)
  8. stringToURI(String[] str)
  9. uri(String host, String prefix, String path)