Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 是否从RESTWeb服务向客户端发送.apk文件?_Java_Android_Rest - Fatal编程技术网

Java 是否从RESTWeb服务向客户端发送.apk文件?

Java 是否从RESTWeb服务向客户端发送.apk文件?,java,android,rest,Java,Android,Rest,我想从JavaRESTfulWeb服务将我的android.apk文件发送到我的客户端(浏览器)。但是它会生成一个名为“MyPath”的文件,没有任何文件扩展名(require.apk)。请提前感谢 @Path("MyPath") public class MyPathResource { @Context private UriInfo context; /** * Creates a new instance of MyPathResource

我想从JavaRESTfulWeb服务将我的android.apk文件发送到我的客户端(浏览器)。但是它会生成一个名为“MyPath”的文件,没有任何文件扩展名(require.apk)。请提前感谢

@Path("MyPath")
public class MyPathResource {
    @Context
    private UriInfo context;

    /**
     * Creates a new instance of MyPathResource
     */
    public MyPathResource() {
    }

    @GET
    @Produces("application/vnd.android.package-archive")
    public File getFile() {
        // return my file
        return new File("E:\\CommandLineAndroidProjet1\\bin\\FirstCommandLineApp-release.apk");
    }
}

尝试创建一个显式的
javax.ws.core.Response

return Response.status(Response.Status.OK)
                .entity(entity)
                .header("Content-Disposition", "attachment; filename=" + fileName)
                .build();
实体
是作为字节数组的文件,而
文件名
是带有
.apk
后缀的文件名