Advertisement
TrodelHD

Untitled

May 9th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. package DataSaveSystem;
  2.  
  3. import java.io.File;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.List;
  7.  
  8. import Converter.Converter;
  9.  
  10. public class getFullProjekt {
  11.  
  12. static ArrayList<File> AllFiles;
  13.  
  14. public static byte[][] getFullProjekt(String Projekt){
  15.  
  16. AllFiles = new ArrayList<>();
  17.  
  18. listf("Projekts/"+Projekt);
  19. int toCutChars = 10+Projekt.length();
  20. byte[][] re = new byte[(AllFiles.size()*2)+2][];
  21. for(int i = 0; i < AllFiles.size();i++){
  22. String Path = AllFiles.get(i).getPath();
  23. re[i*2+2] = Path.substring(toCutChars, Path.length()).getBytes();
  24. re[i*2+3] = Converter.toByteArray(AllFiles.get(i).getPath());
  25. }
  26. re[0]= new String("fullProjekt").getBytes();
  27. re[1]= new String(Projekt).getBytes();
  28. //File ProjektFolder = new File("Projekts/"+Projekt);
  29.  
  30. return re;
  31. }
  32. private static List<File> listf(String directoryName) {
  33. File directory = new File(directoryName);
  34.  
  35. List<File> resultList = new ArrayList<File>();
  36.  
  37. // get all the files from a directory
  38. File[] fList = directory.listFiles();
  39. resultList.addAll(Arrays.asList(fList));
  40. for (File file : fList) {
  41. if (file.isFile()) {
  42. AllFiles.add(file);
  43. } else if (file.isDirectory()) {
  44. resultList.addAll(listf(file.getPath()));
  45. }
  46. }
  47. return resultList;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement