OK I have so much questions regarding my file sharing application that I don't know where to start. My Java knowledge is very limited and I will be satisfied with any help you provide me.
That being said, here come the questions.
Firstly, I'm working on a user login method that needs to look sort of like this:
import java.io.File;
import java.util.ArrayList;
public class User {
String username;
String IPAdresa;
public User(String username, String IPAdresa) {
this.username = username.toLowerCase();
this.IPAdresa = IPAdresa;
}
public void fileList() {
ArrayList<String> list = new ArrayList<String>();
File folder = new File("C:\\userfolder");
File[] files = folder.listFiles();
for (int i = 0; i < files.length; i++) {
list.add(i, files[i].toString());
}
}
}
As you can see I have user class that contains parameters regarding user, such as username and IPAddress, and also fileList method that lists files from a certain folder and creates the arraylist containing those file names as strings.
The next thing I have to do is make a class or a method that provides search function to clients/users. For example, when users logs on to the application, he will want to search for a certain file and also he will provide the list of files from his shared folder to other users. The way I understood my menthor, the Request class needs to contain for each loops that are able to search within the users respective file lists. I'm not sure how to pull that off and I have a lot of problems regarding working with array lists.
This how it's supposed to look like approximately: (I'm using sort of pseudo-code for this one so far)
public class RequestForFile {
ArrayList list = new ArrayList();
User user = new User("Slavisha","123.23.34.45");
public RequestForFile() {
list.add(user);
foreach (User user in userlist) {
foreach (String str in User.fileList()) {
if (str == request)
...
}
}
}
}
Next question: How do users log in to Java application? I've been thinking about it all day and tried to get around it but I just failed. I don't have GUI/Swing yet, hope to do it in the end.
I have 3 more classes that represent Client, Server and HandleClient.
As I said any contribution is welcome. I will be back with more questions for sure. Thanks