ok so i've made it not printwriter but it still scrambles up all the images and stuff. i've made just a client and server program.
Client
Code:
public class client
{
public static void main ( String[] args ) throws IOException
{
File file = new File ( args[0] );
FileInputStream fileStream = new FileInputStream ( file );
Socket socket = new Socket ( "laptop", 8080 );
OutputStream out = socket.getOutputStream ();
int c;
while ( ( c = fileStream.read () ) != -1 )
{
out.write ( c );
}
out.flush ();
}
}
Server
Code:
public class server
{
public static void main ( String[] args )
{
File file = new File ( "c:\\kobe.jpg" );
try
{
ServerSocket socket = new ServerSocket ( 8080 );
Socket s = socket.accept ();
BufferedReader input = new BufferedReader ( new InputStreamReader ( s.getInputStream () ) );
DataOutputStream out = new DataOutputStream ( new FileOutputStream ( file ) );
int c;
while ( ( c = input.read () ) != -1 )
{
out.write ( c );
//System.out.print(c);
}
out.flush ();
}
catch ( IOException e )
{
}
}
}
it still doesnt work. could you post your solution to this or a sample program that you've done that works please? i'm really at a fix here.