long start = System.currentTimeMillis();
Socket client = serverSocket.accept();
System.out.println("S: Receiving to client...");
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
String str = in.readLine();
System.out.println("S: Received: '" + str + "'");
byte [] mybytearray = new byte [filesize];
InputStream is = client.getInputStream();
FileOutputStream fos = new FileOutputStream("QUANTITATOSERVER.xml");
BufferedOutputStream bos = new BufferedOutputStream(fos);
bytesRead = is.read(mybytearray,0,mybytearray.length);
bytesRead = is.read(mybytearray, current, (mybytearray.length-current));
if(bytesRead >= 0) current += bytesRead;
bos.write(mybytearray, 0 , current);
long end = System.currentTimeMillis();
System.out.println(end-start);
File myArticoli = new File ("articoli.xml");
FileInputStream fis = new FileInputStream(myArticoli);
BufferedInputStream bis = new BufferedInputStream(fis);
byte [] mybytearray3 = new byte [(int)myArticoli.length()];
bis.read(mybytearray3,0,mybytearray3.length);
OutputStream os = client.getOutputStream();
os.write(mybytearray3,0, mybytearray3.length);
File myLogspesa = new File ("logspesa.xml");
FileInputStream fis2 = new FileInputStream(myLogspesa);
BufferedInputStream bis2 = new BufferedInputStream(fis2);
byte [] mybytearray2 = new byte [(int)myLogspesa.length()];
bis2.read(mybytearray2,0,mybytearray2.length);
OutputStream os2 = client.getOutputStream();
os2.write(mybytearray2,0, mybytearray2.length);
System.out.println("S: Error");
System.out.println("S: Done.");
System.out.println("S: Error");
public static void main (String a[]) throws SQLException, ClassNotFoundException {
Thread desktopServerThread = new Thread(new TCPDesktopServer());
desktopServerThread.start();
static public void invioFileXMLtoAndroid() throws IOException, SQLException, ClassNotFoundException{
XmlWriter xmlwriterArt = new XmlWriter(new java.io.FileWriter("articoli.xml"));
XmlWriter xmlwriterLog = new XmlWriter(new java.io.FileWriter("logspesa.xml"));
Vector<ArticoloBean> VetArt = ArticoloDB.getAllArticolo(DBConnection.getBDConnection().getConnection());
Vector<LogSpesaBean> VetLog = LogSpesaDB.getLogSpesa(DBConnection.getBDConnection().getConnection(),CalendarUtility.getTodayLong());
for(int j=0; j<VetArt.size(); j++)
xmlwriterArt.writeObject(VetArt.elementAt(j));
for(int j=0; j<VetLog.size(); j++)
xmlwriterLog.writeObject(VetLog.elementAt(j));