Skip to content

Commit 3b3344d

Browse files
author
quaa
committed
Updated readme, and cleaned up some output of the client and server
1 parent 45d3a8c commit 3b3344d

File tree

5 files changed

+45
-12
lines changed

5 files changed

+45
-12
lines changed

README

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1-
A simple java file sync program I currently am developing for my
2-
networking class
1+
Java File Sync
2+
Brian Tannous
3+
November 2010
34

4-
This program is very simple but effective.
5+
------------------------------About------------------------------
6+
Java File Sync is a simple directory tree synchronization program
7+
written in java. Jfs is currently a command line only program
8+
and is can be ran anywhere. It requires a sever to host the sync
9+
directories. You can easily sync any directory with any machine
10+
on any network. Jfs uses sockets to communicate back and forth
11+
and is fairly efficient.
12+
13+
---------------------------How to Use----------------------------
14+
Usage is extremely simple, below are examples of both client and
15+
server arguments. A pre-compiled .jar file is found in the
16+
executables directory.
17+
18+
---Server
19+
The server is a vital part of Jfs as it is what hosts the syncing
20+
directories. You will need to run Jfs server as:
21+
22+
java -jar jfs.jar -s
23+
24+
The Jfs server will run until you choose to close it by CTL + C
25+
26+
---Client
27+
The client is the machine you currently would like to sync any
28+
given directory with the server.
29+
You will need to run Jfs client as:
30+
31+
java -jar jfs.jar -c Server.IP DirectoryToSync
32+
ex: java -jar jfs.jar -c 192.168.1.100 ~/working/
33+
34+
The Jfs client will connect to the given server and close when
35+
syncing is finished.

TODO.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

executable/jfs.jar

10.1 KB
Binary file not shown.

src/net/quaa/jfs/Client.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public Client(String dirName, String fullDirName, String serverIP, int port) {
3131
System.out.println("Client Selected!");
3232
System.out.println("Dir to sync: " + dirName);
3333
System.out.println("Server IP: " + serverIP);
34+
System.out.print("Syncing");
3435
}
3536

3637
public void runClient() throws Exception {
@@ -61,10 +62,13 @@ public void runClient() throws Exception {
6162
oos.close();
6263
ois.close();
6364
sock.close();
65+
System.out.println();
66+
System.out.println("Finished sync");
6467
}
6568

6669
// Process all files and directories under dir
6770
private static void visitAllDirsAndFiles(File dir) throws Exception{
71+
System.out.print(".");
6872
Vector<String> vec = new Vector<String>();
6973
vec.add(dir.getName());
7074
vec.add(dir.getAbsolutePath().substring((dir.getAbsolutePath().indexOf(fullDirName) + fullDirName.length())));
@@ -126,7 +130,7 @@ private static void sendFile(File dir) throws Exception {
126130
oos.flush();
127131
reinitConn();
128132

129-
printDebug(true, dir);
133+
// printDebug(true, dir);
130134
}
131135

132136
private static void receiveFile(File dir) throws Exception {
@@ -141,13 +145,14 @@ private static void receiveFile(File dir) throws Exception {
141145

142146
reinitConn();
143147

144-
printDebug(false, dir);
148+
// printDebug(false, dir);
145149
}
146150

147151
private static void updateFromServer() throws Exception {
148152
Boolean isDone = false;
149153
Boolean nAll = false;
150154
while(!isDone) {
155+
System.out.print(".");
151156
String path = (String) ois.readObject();
152157

153158
if(path.equals(DONE)) {

src/net/quaa/jfs/Server.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ public void startServer() throws Exception {
2929
servsock = new ServerSocket(PORT_NUMBER);
3030
while (true) {
3131
sock = servsock.accept();
32+
3233
ois = new ObjectInputStream(sock.getInputStream());
3334

3435
baseDir = (String) ois.readObject();
3536
File fBaseDir = new File(baseDir);
3637
Boolean baseDirExists = fBaseDir.exists();
3738

39+
System.out.println("New client connected! IP: " + sock.getInetAddress().toString() + " Directory: " + baseDir);
40+
3841
if(!baseDirExists)
3942
fBaseDir.mkdir();
4043

@@ -113,6 +116,7 @@ public void startServer() throws Exception {
113116
oos.close();
114117
ois.close();
115118
sock.close();
119+
System.out.println("Finished sync");
116120
}
117121
}
118122

0 commit comments

Comments
 (0)