Example usage for org.apache.commons.net.tftp TFTPClient open

List of usage examples for org.apache.commons.net.tftp TFTPClient open

Introduction

In this page you can find the example usage for org.apache.commons.net.tftp TFTPClient open.

Prototype

public void open(int port) throws SocketException 

Source Link

Document

Opens a DatagramSocket on the local host at a specified port.

Usage

From source file:org.jnode.protocol.tftp.TFTPURLConnection.java

/**
 * @see java.net.URLConnection#getInputStream()
 *//*ww  w . jav  a2s.  c  om*/
public InputStream getInputStream() throws IOException {
    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    final TFTPClient tftp = new TFTPClient();
    final InetAddress hostAddr = InetAddress.getByName(host);
    tftp.open(TFTP.DEFAULT_PORT);
    try {
        tftp.receiveFile(path, TFTP.BINARY_MODE, os, hostAddr);
    } finally {
        tftp.close();
    }
    return new ByteArrayInputStream(os.toByteArray());
}