type main + ctrl + space
Tag Archives: Java
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
JCP – Java Community Web Site
JCP stands for Java Community Process. This website is a one shop stop to all JSR (Java Specification Requests). Each and every new Java API is born here!
Eclipse / Maven – Missing artifact jdk.tools:jdk.tools:jar:1.6
To resolve this error on your Eclipse all you have to do is
1. Copy the tools.jar from the jdk distribution on your machine to your local maven repository
mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.6 -Dfile=tools.jar -DgeneratePom=true
2. Add the following dependency in your pom.xml
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.6</version>
</dependency>