Example usage for org.apache.wicket.util.file Files readBytes

List of usage examples for org.apache.wicket.util.file Files readBytes

Introduction

In this page you can find the example usage for org.apache.wicket.util.file Files readBytes.

Prototype

public static byte[] readBytes(final File file) throws IOException 

Source Link

Document

read binary file fully

Usage

From source file:de.alpharogroup.wicket.base.util.application.ApplicationExtensions.java

License:Apache License

/**
 * Gets the resource stream from the given parameters.
 *
 * @param file//from  www  .ja va 2  s  .  c  o  m
 *            the file
 * @param contentType
 *            the content type
 * @return the resource stream
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public static IResourceStream getResourceStream(final java.io.File file, final String contentType)
        throws IOException {
    return new ByteArrayResourceStreamWriter() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getContentType() {
            return contentType;
        }

        @Override
        protected byte[] load() throws IOException {
            final byte[] data = Files.readBytes(file);
            return data;
        }
    };
}

From source file:de.alpharogroup.wicket.base.util.application.ApplicationExtensions.java

License:Apache License

/**
 * Gets the resource stream from the given parameters.
 *
 * @param application/*ww w .  j  a va 2s .  c  o  m*/
 *            the application
 * @param path
 *            the path
 * @param contentType
 *            the content type
 * @return the resource stream
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public static IResourceStream getResourceStream(final WebApplication application, final String path,
        final String contentType) throws IOException {
    return new ByteArrayResourceStreamWriter() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getContentType() {
            return contentType;
        }

        @Override
        protected byte[] load() throws IOException {
            final String realPath = ApplicationExtensions.getRealPath(application, path);
            final File file = new File(realPath);
            final byte[] data = Files.readBytes(file);
            return data;
        }
    };
}

From source file:org.jaulp.wicket.base.util.application.ApplicationUtils.java

License:Apache License

/**
 * Gets the resource stream from the given parameters.
 *
 * @param application/*  ww  w . ja va  2  s  .  c  om*/
 *            the application
 * @param path
 *            the path
 * @param contentType
 *            the content type
 * @return the resource stream
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public static IResourceStream getResourceStream(final WebApplication application, final String path,
        final String contentType) throws IOException {
    return new ByteArrayResourceStreamWriter() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getContentType() {
            return contentType;
        }

        @Override
        protected byte[] load() throws IOException {
            final String realPath = ApplicationUtils.getRealPath(application, path);
            final File file = new File(realPath);
            byte[] data = Files.readBytes(file);
            return data;
        }
    };
}

From source file:org.jaulp.wicket.base.util.application.ApplicationUtils.java

License:Apache License

/**
 * Gets the resource stream from the given parameters.
 *
 * @param file//w  w w. j av a  2  s .c o m
 *            the file
 * @param contentType
 *            the content type
 * @return the resource stream
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public static IResourceStream getResourceStream(final java.io.File file, final String contentType)
        throws IOException {
    return new ByteArrayResourceStreamWriter() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getContentType() {
            return contentType;
        }

        @Override
        protected byte[] load() throws IOException {
            byte[] data = Files.readBytes(file);
            return data;
        }
    };
}