Java HTTP Port Find exportResource(Class fromClass, String resourceName, String exportPath)

Here you can find the source of exportResource(Class fromClass, String resourceName, String exportPath)

Description

export Resource

License

Open Source License

Declaration

public static void exportResource(Class fromClass, String resourceName, String exportPath)
            throws IOException, URISyntaxException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;

public class Main {
    public static void exportResource(Class fromClass, String resourceName, String exportPath)
            throws IOException, URISyntaxException {
        InputStream in = null;//from   ww w .ja va  2  s  .c o  m
        OutputStream out = null;
        try {
            in = fromClass.getResourceAsStream(resourceName);
            if (in == null) {
                throw new IOException("Cannot get resource \"" + resourceName + "\" from jar.");
            }

            int readBytes;
            byte[] buffer = new byte[4096];
            out = new FileOutputStream(exportPath);
            while ((readBytes = in.read(buffer)) > 0) {
                out.write(buffer, 0, readBytes);
            }
        } finally {
            if (in != null)
                in.close();

            if (out != null)
                out.close();
        }
    }
}

Related

  1. canConnect(String host, int port)
  2. canConnectOn(String host, int port)
  3. createUnresolved(String host, int port)
  4. doSend(String command, String server, String port)
  5. executeHttpCommand(String host, int port, String request, String charset)
  6. findAvailablePort()
  7. findAvailablePort()
  8. findAvailablePort()
  9. findAvailablePort(int min, int max)