Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int byteSize = 50000;
- public byte[] byteArray = new byte[byteSize];
- public ByteBuffer byteBuffer = ByteBuffer.allocate(byteSize);
- private void writeToRawInFile(byte[] bData) {
- try {
- int index = 4;
- byteBuffer = null;
- byteBuffer = ByteBuffer.allocate(bData.length);
- byteBuffer.put(bData);
- byteBuffer.flip();
- if(byteBuffer.get(index) == 0){
- factoryType.fileServer.fc.write(byteBuffer);
- }else{
- decompressByteArray(byteBuffer.)
- }
- } catch (Exception e) {
- out.println("expMsg .writeToRawInFile()=" + e.getMessage());
- e.printStackTrace();
- }
- if (byteBuffer != null) {
- byteBuffer.clear();
- }
- }
- } catch (Exception e) {
- out.println("expMsg .writeToRawInFile()=" + e.getMessage());
- e.printStackTrace();
- }
- if (byteBuffer != null) {
- byteBuffer.clear();
- }
- }
- public byte[] decompressByteArray(byte[] bytes){
- ByteArrayOutputStream baos = null;
- Inflater iflr = new Inflater();
- iflr.setInput(bytes);
- baos = new ByteArrayOutputStream();
- byte[] tmp = new byte[4*1024];
- try{
- while(!iflr.finished()){
- int size = iflr.inflate(tmp);
- baos.write(tmp, 0, size);
- }
- } catch (Exception ex){
- } finally {
- try{
- if(baos != null) baos.close();
- } catch(Exception ex){}
- }
- return baos.toByteArray();
- }
- decompressByteArray(byteBuffer.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement