1

I am programming a file transfer, and i am having troubles with it. In my current location i have created a folder called "Server Folder", where i will have files that the Client can transfer (I will be transfered with the same name, to the workspace directory), But every time i try to access it, it fails.

FILE_SERVER_PATH = "./ServerFolder/";

File fileToRead = new File(FILE_SERVER_PATH + fileName);
        fileToRead = fileToRead.getParentFile();


        if(fileToRead.exists()){
            FileInputStream readingBuffer = new FileInputStream(fileToRead);

fileName is received throw datagram, and the name is correct. It always fails in the condition --> fileToRead.exists()

Can anyone please give me a tip?

Thx! :-)

4

1 に答える 1

1

フォルダパスを絶対パスとして使用してみてください。

役立つと機能します...現在のディレクトリは、実行時にどのディレクトリにいるかがわかっている場合にのみ機能します。

于 2013-03-08T17:47:08.330 に答える