All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.evosuite.runtime.vnet.RemoteFile Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
/**
 * Copyright (C) 2010-2017 Gordon Fraser, Andrea Arcuri and EvoSuite
 * contributors
 *
 * This file is part of EvoSuite.
 *
 * EvoSuite is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3.0 of the License, or
 * (at your option) any later version.
 *
 * EvoSuite is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with EvoSuite. If not, see .
 */
package org.evosuite.runtime.vnet;

import org.evosuite.runtime.util.ByteDataInputStream;

import java.io.InputStream;

/**
 * Class representing a file on a remote host.
 * A remote file can only be created once, and cannot be modified, just read.
 *
 * Created by arcuri on 12/6/14.
 */
public class RemoteFile {

    private final String url;
    private final byte[] data;


    public RemoteFile(String url, byte[] data) throws IllegalArgumentException{
        if(url == null || data == null){
            throw new IllegalArgumentException("Null inputs");
        }
        this.url = url;
        this.data = data;
    }

    public RemoteFile(String url, String data) throws IllegalArgumentException {
        this(url,data==null ? null : data.getBytes());
    }


    /**
     *
     * @return a new {@code InputStream} instance that can be used to read the content of this remote file
     */
    public InputStream getInputStream(){
        return new ByteDataInputStream(data);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy