Strumenti Utente

Strumenti Sito


lpr-b-2007-2008:codicescrittore
import java.io.*;
import client.*;
 
public class CopyIn {
 
        public static void main(String[] args) {
                try {
                        System.out.println("Opening remote file ...");
                        RemoteOutputStream ros = new RemoteOutputStream(args[0],Boolean.parseBo
olean(args[1]));
                        System.out.println("Opening local file ...");
                        FileInputStream        is  = new FileInputStream(args[0]);
                        final int MAXBUF = 1024; 
                        byte [] buffer = new byte[MAXBUF];
                        System.out.print("Copying ."); System.out.flush();
                        int letti = is.read(buffer, 0, MAXBUF);
                        while(letti > 0) {
                                System.out.print(".");System.out.flush();
                                ros.write(buffer, 0, letti);
                                letti = is.read(buffer, 0, MAXBUF);
                        }
                        System.out.println("\nClosing remote file");
                        ros.close();
                        System.out.println("Closing local file");
                        is.close();
                } catch (Exception e) {
                        e.printStackTrace();
                        return;
                }
        }
 
}
lpr-b-2007-2008/codicescrittore.txt · Ultima modifica: 19/09/2008 alle 14:08 (16 anni fa) da 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki