Admin
Jan 12, 2023
14 comments
955
Method #1 ObjectMapper objectMapper = new ObjectMapper(); String containerMatrixJSON = "{\"container_metrics\":{\"cpuRequest\":{\"results\":{\"general_info\":{\"sum\":4.4,\"mean\":1.1,\"units\":\"cores\"}}},\"cpuLimit\":{\"results\":{\"general_i...
Snippet
Java - Convert a JSON or Nested JSON into a Map
Admin
Feb 25, 2022
13 comments
1.06K
2.1. ClassLoader.getResourceAsStream() Use the getResourceAsStream() method to get the InputStream when reading a file from inside a jar file. Always use this method on the ClassLoader instance. private InputStream getFileAsIOStream(final St...
Snippet
Read a file from the ‘resources’ folder
Admin
Feb 09, 2021
20 comments
709
String jsonData = "[\r\n" + " {\r\n" + " \"CompType\": \"Substrate\",\r\n" + " \"CompName\": \"80101-106DSA\",\r\n" + " \"CompRev\": \"BA\",\r\n" + " },\r\n" + " {\r\n" + " \"CompType\": \"Substrate\",\r\n" + " \"CompName\": \...
Snippet
Read JSON data into a list
Admin
May 26, 2018
17 comments
431
Client Code import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.Socket; public class Client { public static void main (String [] args ) throws IOExc...
Snippet
Sending files over network in Java
Admin
May 25, 2018
13 comments
652
package com.test1; import java.awt.AlphaComposite; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public c...
Snippet
Image Resizing in Java
@Override public void onClick(View v) { view = v; int id = v.getId(); switch (id) { case R.id.check_permission: if (checkPermission()) { Snackbar.make(view, "Permission already grant...
Snippet
Request Permission Code in Android