Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. public int byteSize = 50000;
  2. public byte[] byteArray = new byte[byteSize];
  3. public ByteBuffer byteBuffer = ByteBuffer.allocate(byteSize);
  4.  
  5. private void writeToRawInFile(byte[] bData) {
  6. try {
  7. int index = 4;
  8. byteBuffer = null;
  9. byteBuffer = ByteBuffer.allocate(bData.length);
  10.  
  11. byteBuffer.put(bData);
  12. byteBuffer.flip();
  13.  
  14.  
  15. if(byteBuffer.get(index) == 0){
  16. factoryType.fileServer.fc.write(byteBuffer);
  17. }else{
  18. decompressByteArray(byteBuffer.)
  19. }
  20. } catch (Exception e) {
  21. out.println("expMsg .writeToRawInFile()=" + e.getMessage());
  22. e.printStackTrace();
  23. }
  24. if (byteBuffer != null) {
  25. byteBuffer.clear();
  26. }
  27. }
  28.  
  29. } catch (Exception e) {
  30. out.println("expMsg .writeToRawInFile()=" + e.getMessage());
  31. e.printStackTrace();
  32. }
  33. if (byteBuffer != null) {
  34. byteBuffer.clear();
  35. }
  36. }
  37.  
  38. public byte[] decompressByteArray(byte[] bytes){
  39.  
  40. ByteArrayOutputStream baos = null;
  41. Inflater iflr = new Inflater();
  42. iflr.setInput(bytes);
  43. baos = new ByteArrayOutputStream();
  44. byte[] tmp = new byte[4*1024];
  45. try{
  46. while(!iflr.finished()){
  47. int size = iflr.inflate(tmp);
  48. baos.write(tmp, 0, size);
  49. }
  50. } catch (Exception ex){
  51.  
  52. } finally {
  53. try{
  54. if(baos != null) baos.close();
  55. } catch(Exception ex){}
  56. }
  57.  
  58. return baos.toByteArray();
  59. }
  60.  
  61. decompressByteArray(byteBuffer.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement