如何在客户端计算机中存储文件? [英] How to store files in client machine?

查看:98
本文介绍了如何在客户端计算机中存储文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

File dir = new File(System.getProperty("user.home")+"\\Desktop\\" + svc);
        dir.mkdir();
        File f;
        f = new File(System.getProperty("user.home")+"\\Desktop\\" + svc
                + "\\" + logFile + "_" + System.currentTimeMillis()
                + ".txt");

我正在使用此代码将文件存储在用户(客户端)计算机中.但是它将文件存储在服务器计算机中.有人可以帮助我吗?我已将War文件部署在Unix服务器中.

I am using this code to store the files in the user(client) machine.But it is storing the files in the server machine.Can anyone help me on this? I have deployed my war file in unix server.

推荐答案

从服务器上运行的软件在客户端计算机上保存文件并不那么简单.

Saving a file on a client machine from software running on a server is not as simple as that.

服务器无法直接访问任何客户端的文件系统-如果是这种情况,那将是非常不安全的.

Servers do not have direct access to the file system of any client - it would be very insecure if that were the case.

最简单的方法是使服务器返回一个带有链接的网页,用户可以单击该链接下载文件.

The simplest way to do this is by making the server return a web page with a link which the user can click to download the file.

您还可以做一些更复杂的事情,例如编写一个applet,以下载文件(使用某种文件传输协议)并将其保存在本地文件系统中.小程序将需要具有适当的权限(默认情况下,小程序无法访问本地文件系统).

You could also do something more complicated, for example write an applet that downloads the file (using some file transfer protocol) and saves it in the local file system. The applet would need to have the appropriate permissions (by default, applets cannot access the local file system).

这篇关于如何在客户端计算机中存储文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆