Writes a hex dump to a file for a large byte array.

@param fileName output file name
@param data target data
186174
public static final void fileHexDump(String fileName, byte[] data)
   {
      System.out.println("FILE HEX DUMP");
      try
      {
         FileOutputStream os = new FileOutputStream(fileName);
         os.write(ByteArrayHelper.hexdump(data, true, 16, "").getBytes());
         os.close();
      }

      catch (IOException ex)
      {
         ex.printStackTrace();
      }
   }
1088866
public static void writeFile(String filename, String code){
        try {
            FileOutputStream fidout = new FileOutputStream(filename);
            fidout.write(code.getBytes());
            fidout.close();
        } catch (Exception e) {
            System.err.println(e);
        }
    }
1034910
@Override
    public int writeCData(String data) throws IOException
    {
        writeAscii("<![CDATA[");
        int ix = writeCDataContent(data);
        if (ix >= 0) {
            return ix;
        }
        writeAscii("]]>");
        return -1;
    }
586976
public static File writeDataToTempFile(final byte[] data, final String suffix) {
		try {
			File file = File.createTempFile("jk-", suffix);
			return writeDataToFile(data, file);
		} catch (IOException e) {
			JKExceptionUtil.handle(e);
			return null;
		}
	}
1280236
public void write(byte[] b, int off, int len) throws IOException {
        checkForClosed();
        if (b == null) {
            throw new NullPointerException();
        } else if ((off < 0) || (len < 0) || ((off + len) > b.length)) {
            throw new IndexOutOfBoundsException();
        } else if (len == 0) {
            return;
        }
        if (len > bytesLeftInBuffer()) {
            int bytesToWrite = bytesLeftInBuffer();
            write(b, off, bytesToWrite);
            write(b, off + bytesToWrite, len - bytesToWrite);
        } else {
            System.arraycopy(b, off, _buffer, _bufferOffset, len);
            _bufferOffset += len;
            if (bytesLeftInBuffer() == 0) {
                writeBufferToFile();
            }
        }
    }
713512
public void write(DataOutput out) throws IOException {
    out.writeLong(version);
    Text.writeString(out, dir);
    out.writeLong(gen);
  }
1216097
public static void write2File(String filePath, byte[] byteData) {
        try {
            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(new File(filePath)));
            bufferedOutputStream.write(byteData);
            bufferedOutputStream.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
21209
static String toHexString(byte[] data) {
    char[] chArray = new char[data.length * 2];
    int pos = 0;
    for (byte b : data) {
      chArray[pos++] = HEX_CHARS[(b >> 4) & 0x0f];
      chArray[pos++] = HEX_CHARS[b & 0x0f];
    }
    return new String(chArray);
  }
65710
@Override
	public void write(byte data[], int offset, int len) throws IOException
    {
        if ((capacity - size) < len)
            flush();
        
        // Do we have enough space ?
        if (capacity >= len)
        {
            System.arraycopy(data, offset, buffer, size, len);
            size += len;
        }
        else
        {
            // Too big, write it directly ...
            out.write(data, offset, len);
        }
    }
448488
public void write(String filename)
	{
		try
		{
			write(new FileOutputStream(filename));
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
	}
1277665
public static void writeOutContent(final byte[] data, final String filename, final String mime) {
        writeOutContent(data, filename, mime, true);
    }
763617
public static void write(final String data, final Writer output) throws IOException {
		if (data != null) {
			output.write(data);
		}
	}
132792
public void writeCData(String data) throws XMLStreamException {
		try {
			this.checkPendingATEvents();
			// CDATA
			this.writeCharacters(data);
		} catch (Exception e) {
			throw new XMLStreamException(e.getLocalizedMessage(), e);
		}
	}
777338
public void setData(byte[] data) {
        byte[] copy = new byte[data.length];
        System.arraycopy(data, 0, copy, 0, data.length);
        this.data = copy;
    }
86379
@SuppressWarnings("unused")
    private static final void dump(IoBuffer data) {
        log.debug("Hex: {}", data.getHexDump());
        int pos = data.position();
        byte[] bar = new byte[data.limit() - data.position()];
        data.get(bar);
        log.debug("Str {}", new String(bar));
        bar = null;
        data.position(pos);
    }
921616
public static void write(byte[] data, OutputStream os, boolean closeSink) {
        try {
            os.write(data);
        } catch (IOException e) {
            throw E.ioException(e);
        } finally {
            if (closeSink) {
                close(os);
            }
        }
    }
1279678
public static String data2hex(byte[] data) {
        StringBuffer ret = new StringBuffer();

        for (int i = 0; i < data.length; i++) {
            String st = Integer.toHexString(data[i]);
            if (st.length() == 1) {
                st = '0' + st;
            }
            st = st.substring(st.length() - 2);
            ret.append(st).append(" ");
        }

        return ret.toString();
    }