I think JSR 75 File Connection API is what I need. I hope I can change and understand the dir's path, because in this moment I have something like this:
Code:
String request;
// Allows to access the webserver content like resources
Class resource = this.getClass();
......................................................
// READ THE BUFFER and if is not empty do this:
request = new String(buffer,0,length);
// Obtaing the resource path specified by the get request
String path = request.substring(4,request.indexOf("HTTP") - 1);
// if is a directory sends the index.html
if(path.endsWith("/"))
path += "index.html";
// Adds the request path to the path specified
path = "/httpdocs" + path;
// Open the request path with the help of resource as Stream
InputStream reader = resource.getResourceAsStream(path);
// If the reader is null, the request is not found, sends a error
if(reader == null)
// stop here because the httpdocs directory was't found :(
else
{
// the httpdocs dir was found so read the buffer, etc.
}
I think instead of that peace of code I need to do something like dir = (FileConnection)Connector.open("file://localhost/" + currDirName); but I don't understand where to get this file on localhost and how to get the resource as a stream for this path.
Someone have an ideea ?