Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafael Toledo rafaeltoledo

View GitHub Profile
@rafaeltoledo
rafaeltoledo / Base64.java
Created May 11, 2015
Convert Image to Base64
View Base64.java
public static String encodeBase64(String path) {
try {
File file = new File(path);
FileInputStream imageInFile = new FileInputStream(file);
byte imageData[] = new byte[(int) file.length()];
imageInFile.read(imageData);
imageInFile.close();
return Base64.encodeToString(imageData, Base64.DEFAULT);
} catch (Exception e) {
View task.groovy
task checkstyle(type: Checkstyle) {
configFile file("$project.rootDir/config/checkstyle/checkstyle.xml")
source 'src'
include '**/*.java'
classpath = files()
}
View checkstyle.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="GenericWhitespace" />
</module>
View unformatted.java
package net.rafaeltoledo.codequality;
import android.support.v7.app.AppCompatActivity;
import java.util.List;
public class MyActivity extends AppCompatActivity {
List< String > myList;
}
View output1
Executing external task ‘checkstyle’…
Parallel execution is an incubating feature.
[ant:checkstyle] [...]MyActivity.java:9:10: ‘<’ é seguido de espaço em branco.
[ant:checkstyle] [...]MyActivity.java:9:17: ‘>’ é precedido por espaço em branco.
:app:checkstyle FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ‘:app:checkstyle’.
View success-output
Executing external task ‘checkstyle’…
Parallel execution is an incubating feature.
:app:checkstyle
BUILD SUCCESSFUL
Total time: 2.622 secs