开发者

Create file using File object?

If i pass this fil Obje开发者_如何学编程ct to the Server can i create the same file there??

File fil=new File("D://Resume.doc");


File object just holds a reference to physical file in your FS. You can't regenerate if you simply pass it to server


The File instance names a file, and is distinct from the actual file storage itself.

If you serialize this to the server, the server may be able to create the file locally, although this has no relation to the fact that it was serialized from the client, and will behave exactly as if you called new File('D://resume.doc') on the server.

Either way, it will be a local copy of the file on the server that you open, not the copy on the client.

To open a client's file on the server, you will either need to use a networked file system (e.g. Windows Shares/Samba) or you have the client send the contents of the file to the server. Commons FileUpload, which provides robust file upload functionality for web applications, could be useful here.


can i create the same file there??

No, you need to pass on the bytes representing the file to the server (in your case a MS Word file) for the server to re-create the file there i.e. similar to uploading a file. The specifics depend on what kind of server you have and which protocol you are using.


As long as its not saved on the server yes, otherwise you will get a file name conflict

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜