some recommendation? my client receives the "file" but does not do any method to accept it, my client just sends the command to make it run on the server.
this is my download method in my class commands
public void download (String filename){
File f = new File(path + filename);
System.out.println("");
System.out.println("Starting");
System.out.println(">>Sending File : "+ filename + " " );
System.out.println(">>Please wait...");
try{if(f.exists()){
FileInputStream fis = new FileInputStream(Server.s.getInputStream() + path + filename); //linea 87
BufferedOutputStream bout = new BufferedOutputStream(Server.s.getOutputStream());
BufferedInputStream bis = new BufferedInputStream(fis);
while(true){
byte[] buffer = new byte[1024] ;
int i = bis.read(buffer, 0, buffer.length);
if (i == - 1) {
break;
}
bout.write(buffer, 0, i);
bout.flush();
}
}
this is the error that gives me to execute it
java.io.FileNotFoundException:
java.net.SocketInputStream@521e4820
C:\Users\Eduardo\Desktop\Eduardo\Uru\Clases Programacion\POO\CLI\cesar.txt
(El nombre de archivo, el nombre de directorio o la sintaxis de la etiqueta del volumen no son correctos)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at eagz.org.Commands.download(Commands.java:87)
at eagz.org.Menu.menu(Menu.java:52)
at eagz.org.ConexionServer.run(ConexionServer.java:15)
This is my client class
package eagz.org;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Scanner;
public class Cliente {
static int PORT = 9000;
static String IP = "localhost";
static Scanner input = new Scanner (System.in);
public static void main(String[] args){
try {
while(true){
Socket s = new Socket(IP, PORT);
ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
ObjectInputStream ois = new ObjectInputStream(s.getInputStream());
System.out.println(" ");
System.out.println("-- Client Side --");
System.out.println("Connecting to Server -> " + IP + "/" + PORT);
System.out.println("Designated Commands: "+"->Create "+"->Read" + "->Rename "+"->Delete "+"->Download "+"->Upload");
System.out.println("C:>");
String commandmsg = input.nextLine();
oos.writeObject(commandmsg);
Object servermsg = ois.readObject();
System.out.println("From Server :"+ servermsg);
oos.close();
ois.close();
}
}catch(Exception e){
e.printStackTrace();
}
}
}