This is me collection of small codes that have been helped me at some point in my life :D
This is my collections of helpers:
public String convert(InputStream inputStream, Charset charset) throws IOException {
StringBuilder stringBuilder = new StringBuilder();
String line = null;
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, charset))) {
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
}
}
return stringBuilder.toString();
}
It could be, for Java 8
public String convert(InputStream inputStream, Charset charset) throws IOException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, charset))) {
return br.lines().collect(Collectors.joining(System.lineSeparator()));
}
}
public String convert(InputStream inputStream, Charset charset) throws IOException {
return CharStreams.toString(new InputStreamReader(inputStream, charset));
}
For instance, if you want a deserialize a hashmap
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
Type stringStringMap = new TypeToken<HashMap<String, String>>(){}.getType();
Gson().fromJson(myJSON, stringStringMap);
SELECT sql
FROM (
SELECT sql sql, type type, tbl_name tbl_name, name name
FROM sqlite_master
UNION ALL
SELECT sql, type, tbl_name, name
FROM sqlite_temp_master
)
WHERE type != 'meta'
AND sql NOTNULL
AND name NOT LIKE 'sqlite_%'
ORDER BY substr(type, 2, 1), name
SELECT sql
FROM (
SELECT sql sql, type type, tbl_name tbl_name, name name
FROM sqlite_master
UNION ALL
SELECT sql, type, tbl_name, name
FROM sqlite_temp_master
)
WHERE tbl_name LIKE shellstatic()
AND type != 'meta'
AND sql NOTNULL
ORDER BY substr(type, 2, 1), name
find ./* -type f -exec grep -l STRING {} \;