Vuhelper
07-02-2011, 05:16 PM
package main;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class DataSendTester {
public static void main( String[] args ) {
File testF = new File( "test.jpg" );
File result = new File( "TEST/testImg.jpg" );
try {
System.out.println( "Writing..." );
BufferedInputStream in = new BufferedInputStream( new FileInputStream( testF ) );
BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( result ) );
byte[] buffer = new byte[ 4096 ];
int bytesRead;
while ( (bytesRead = in.read( buffer )) != -1 ) {
out.write( buffer, 0, bytesRead );
}
out.flush();
out.close();
System.out.println( "Done." );
} catch ( FileNotFoundException e ) {
e.printStackTrace();
} catch ( IOException e ) {
e.printStackTrace();
}
}
}
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class DataSendTester {
public static void main( String[] args ) {
File testF = new File( "test.jpg" );
File result = new File( "TEST/testImg.jpg" );
try {
System.out.println( "Writing..." );
BufferedInputStream in = new BufferedInputStream( new FileInputStream( testF ) );
BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( result ) );
byte[] buffer = new byte[ 4096 ];
int bytesRead;
while ( (bytesRead = in.read( buffer )) != -1 ) {
out.write( buffer, 0, bytesRead );
}
out.flush();
out.close();
System.out.println( "Done." );
} catch ( FileNotFoundException e ) {
e.printStackTrace();
} catch ( IOException e ) {
e.printStackTrace();
}
}
}