Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Okay i figured it out with thanks to @Asaph mentioning the downloading going wrong..</p> <p>Basically the downloading was fine, it was the way i was writing the file. </p> <p>When im downloading projects, im downloading the source and binaries, but i was writing both files as if they were the same.</p> <p>So changed the code to check the file type and then use the appropriate writer when necessary. If by some miracle someone has the same issue or is doing something similar here is the code:</p> <p><em><strong>(Note this was just written 5 second ago to fix the problem and is very poorly written, im about to refactor it myself, but i cant do everything for you)</em></strong></p> <pre><code>public void download(String project, String version, String location) { for(S3ObjectSummary s: getObjectList()) { String[] data = s.getKey().split("/"); if(data[0].equals(project) &amp;&amp; data[1].equals(version)) { S3Object object = s3.getObject(s3BucketName,s.getKey()); InputStream input = object.getObjectContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(input)); File file = new File(location +"/"+ data[0] + "/" + data[2] + "/" + data[3] + "/" + data[4]); if(!file.exists()) { try { file.getParentFile().mkdirs(); file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } try { if(data[4].endsWith(".java")) { Writer writer = new OutputStreamWriter(new FileOutputStream(file)); while (true) { String line = reader.readLine(); if (line == null) break; writer.write(line + "\n"); } writer.close(); } else if(data[4].endsWith(".class")) { System.out.println("Writing Classes"); byte[] buffer = new byte[8 * 1024]; try { OutputStream output = new FileOutputStream(file.getAbsolutePath()); try { int bytesRead; while ((bytesRead = input.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } } finally { output.close(); } } finally { input.close(); } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload