Hello all-
I'm trying to pull the contents of a file using only its filename (ex- file.txt).
The catch is I'm doing it via a Java.awt swing applet, and the user has to input the file name into a text box.
The idea is this: Client applet has a JTextField and JTextArea The User client side types in the name of a file hosted on the "server" i.e. file.txt The Server receives the file name, reads the file, and displays the contents of the file back to the client's JTextArea
I've already established a connection between the client and server. The client can properly send a message and it is displayed on the server JTextarea, but I can't seem to figure out the best way to call in the file name using the output from the client as input to a reader class.
so far i've tried:
InputStream is = getClass().getResourceAsStream(clientInput);
The error i'm getting on my [clientInput] is:
method getResourceAsStream cannot be applied to given types
required: java.lang.String
found: java.io.ObjectInputStream
I even tried it simply saying
message = ( String ) input.readObject(); // read new message
if message.equals("text") // if the server receives the message "text"{
displaymessage ("hey look it worked")}
else{
displaymessage ("hey you didn't type text")}
When use the debugger, my curser gets to the if statement, but doesn't find the word "text", and proceeds to use the other message.
note, If requested I will post the entire code...but it is quite long