Pessoal to com um problemão não consigo resolver, eu to tentando fazer o download de um arquivo de uma maquina para uma outra... mas não ta rolando..
Ohh Código abaixo..
----------------------Servidor-----------------------
//package PortalJava;
import java.io.*;
import java.net.*;
public class DicaServer {
String conselho = "teste";
public void go()
{
try
{
ServerSocket sock = new ServerSocket(5000);
while(true)
{
Socket s = sock.accept();
BufferedReader entrada = new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter saida = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
String conselho2 = entrada.readLine();
saida.println(conselho);
saida.flush();
System.out.println(conselho);
System.out.println(conselho2);
entrada.close();
saida.close();
s.close();
}
}catch(IOException ex)
{
ex.printStackTrace();
}
}
public static void main(String[] args)
{
DicaServer d = new DicaServer();
d.go();
}
}
----------------------------Cliente------------------
//package PortalJava;
import java.net.*;
import java.io.*;
import javax.swing.*;
public class DicaCliente {
public void go()
{
try
{
Socket s = new Socket("localhost", 5000);
BufferedReader entrada = new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter saida = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
saida.println("teste222222");
saida.flush();
String conselho = entrada.readLine();
JOptionPane.showMessageDialog(null,conselho);
System.out.println("Conectado a: " + s.getLocalAddress() + " Pela porta: " + s.getPort());
entrada.close();
saida.close();
s.close();
} catch(IOException ex)
{
ex.printStackTrace();
}
}
public static void main(String[] args)
{
DicaCliente dica = new DicaCliente();
dica.go();
}
}
E o erro do Cliente
java.io.FileNotFoundException: C:\Documents and Settings\Administrador\Meus documentos\novo (Acesso negado)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at DicaCliente.go(DicaCliente.java:30)
at DicaCliente.main(DicaCliente.java:59)
Pessoal não e problema de permissão por que to na maquina local como adimistrador e as permissões estão OK