开发者

Accessing files from disk in server root

I need to access some files from my jsp pages.So I kept them inside my server Root.But the no of files are likely to increase.So is there a way by which I can access those fil开发者_StackOverflow社区es from web server root and store them in anywhere in disk ?


you can create a symbolic link.... create a directory in your web root and

  ln -s directory /path/to/files


You need to get the absolute path of the file. Read it using FileInputStream, write to output stream on JSP.

        String file = "/home/mystorage/media/file.dat";
        FileInputStream fileinputstream = new FileInputStream(file);
        int numberBytes = fileinputstream.available();
        byte bytearray[] = new byte[numberBytes];

        fileinputstream.read(bytearray);

        for(int i = 0; i < numberBytes; i++){
            out.println(bytearray[i]);
        }

        fileinputstream.close();

refer Java2s Reading Binary Data

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜