Index: /other-projects/hathitrust/wcsa/vol-checker/src/org/hathitrust/extractedfeatures/VolumeCheck.java
===================================================================
--- /other-projects/hathitrust/wcsa/vol-checker/src/org/hathitrust/extractedfeatures/VolumeCheck.java	(revision 31336)
+++ /other-projects/hathitrust/wcsa/vol-checker/src/org/hathitrust/extractedfeatures/VolumeCheck.java	(revision 31337)
@@ -2,11 +2,17 @@
 
 import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
+import java.io.FileInputStream;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -28,10 +34,9 @@
 	protected static int HASHMAP_INIT_SIZE = 13800000;
 	protected static HashMap<String,Boolean> id_check_ = null;
-	
-    public VolumeCheck() {
-    	
-    }
 
     protected static final String file_ext = ".json.bz2";
+
+    public VolumeCheck() 
+    {}
     
     protected static String full_filename_to_tail(String full_filename)
@@ -148,17 +153,27 @@
 	}
 
-	protected void doRsyncDownload(String full_json_filename)
+	protected BufferedInputStream doRsyncDownload(String full_json_filename)
 	{
 		String json_filename_tail = full_filename_to_tail(full_json_filename);
-		//String cmd = "rsync -av data.analytics.hathitrust.org::features/" + full_json_filename + ".";
-		
-		
-		Runtime rt = Runtime.getRuntime();
-		String[] command = {"rsync","-av","data.analytics.hathitrust.org::features/" + full_json_filename, "."};
-		
+		
+		BufferedInputStream bis = null;
+		
+		Runtime runtime = Runtime.getRuntime();
+		String[] rsync_command = {"rsync","-av","data.analytics.hathitrust.org::features/" + full_json_filename, "."};
 		
 		try {
-			Process proc = rt.exec(command);
-
+			Process proc = runtime.exec(rsync_command);
+			proc.waitFor();
+			System.err.println("*** Rsync finished");
+		
+			FileInputStream fis = new FileInputStream(json_filename_tail);
+			bis = new BufferedInputStream(fis);
+			
+			//Path json_filename_path = Paths.get(json_filename_tail);
+			//byte[] bz_bytes = Files.readAllBytes(json_filename_path);
+			
+			 
+			//response.setContentType("application/json");
+			
 			/*
 			BufferedReader stdInput = new BufferedReader(new 
@@ -182,7 +197,6 @@
 			*/
 
-			proc.waitFor();
-			System.err.println("*** Rsync finished");
-
+			
+			//return bz_bytes;
 		      //System.out.println("Done.");
 		      
@@ -191,4 +205,6 @@
 			e.printStackTrace();
 		}
+		
+		return bis;
 		
 	}
@@ -197,5 +213,5 @@
 	 */
 	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-		PrintWriter pw = response.getWriter();
+		
 		
 		String cgi_ids = request.getParameter("ids");
@@ -205,5 +221,6 @@
 		if (cgi_ids != null) {
 			response.setContentType("application/json");
-	
+			PrintWriter pw = response.getWriter();
+		    
 			String[] ids = cgi_ids.split(",");
 		    int ids_len = ids.length;
@@ -226,5 +243,6 @@
 		else if (cgi_id != null) {
 			response.setContentType("application/json");
-			
+			PrintWriter pw = response.getWriter();
+		    
 			String id = cgi_id;
 			boolean exists = id_check_.get(id);
@@ -242,10 +260,48 @@
 				String full_json_filename = id_to_pairtree_filename(download_id);
 				
-				doRsyncDownload(full_json_filename);
-	
+				BufferedInputStream bis = doRsyncDownload(full_json_filename);
+
+				if (bis == null) {
+					response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Rsync failed");
+				}
+				else {
+					String json_filename_tail = full_filename_to_tail(full_json_filename);
+				
+					response.setContentType("application/x-bzip2");
+					response.setHeader("Content-Disposition", "attachment; filename=\"" + json_filename_tail + "\"");
+
+					
+					//InputStream is=request.getInputStream();
+					OutputStream os=response.getOutputStream();
+					BufferedOutputStream bos = new BufferedOutputStream(os);
+					
+					byte[] buf = new byte[1024];
+					
+					//int num_bytes;
+					while (true) {
+						int num_bytes = bis.read(buf);
+						if (num_bytes == -1) { 
+							break;
+						}
+						bos.write(buf,0,num_bytes);
+					}
+					/*
+					for (int nChunk = bis.read(buf); nChunk!=-1; nChunk = bis.read(buf))
+					{
+					    os.write(buf, 0, nChunk);
+					} 
+					*/
+					
+					//OutputStream os = response.getOutputStream()
+					
+					//os.write(bz_bytes);
+					
+					bis.close();
+				}
 			}
 		}
 		else {
-
+			PrintWriter pw = response.getWriter();
+		    
 			pw.append("General Info: Number of HTRC Volumes in check-list = " + id_check_.size());
 						
