Category Archives: Uncategorized

Sanitizing a byte steam in Java

private InputStream sanitizeStream(InputStream in) throws IOException{

	BufferedInputStream bis = new BufferedInputStream(in);
	OutputStream output = new ByteArrayOutputStream();

	//Sanitize input stream
	int ch;
	while ((ch = bis.read()) != -1) {

		if ((ch == 0x9) || (ch == 0xA) || (ch == 0xD)
		    || ((ch >= 0x20) && (ch = 0xE000) && (ch = 0x10000) && (ch <= 0x10FFFF))) {

			output.write((int) ch);
		}

	}

	InputStream decodedInput = new ByteArrayInputStream(
			((ByteArrayOutputStream) output).toByteArray());

	return decodedInput;
}

Maven Integration for Eclipse JDK Warning

Things to be done to fix the problem

1. Add the following vm argument in the eclipse.ini

Note: This argument should be added before any of the vmargs
-vm C:/path/to/jdk/bin/javaw.exe

2. Change the Installed JREs to point to a JDK instance on your eclipse

Goto Window -> Preferences -> Java -> Installed JREs
Select the intalled JRE and click edit to point to a JDK home directory