Skip to content

Instantly share code, notes, and snippets.

Working from home

Nancy Schorr nmschorr

Working from home
Block or report user

Report or block nmschorr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
/* JavaTestFive by Nancy Schorr, 2017
Demonstrates use of apis to read a json formatted text file and store it as a JSON object for further manipulation.
Also goes to url and reads the data and store it in various objects.
Thanks to for some ideas in this code.
package com.nmschorr;
import static java.lang.System.out;
nmschorr / Url Reading
Last active Oct 14, 2017
The secret to easily reading a URL
View Url Reading
static void readUrlData () throws Exception {
String builderLine;
String locUrlString = "";
System.out.println("\nRunning readUrlData");
HttpURLConnection newUrlConn = (HttpURLConnection) new URL(locUrlString).openConnection();
newUrlConn.setRequestProperty("Accept", "application/json");
if (newUrlConn.getResponseCode() != HttpURLConnection.HTTP_OK) {
System.err.println("Can't connect to Webserver!");
View Pom example
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
View Json Object
JSONArray myJsonArry = new JSONArray(longJsonString);
List<Object> myArrayList = new ArrayList<Object>(toList(myJsonArry));
Collection<Map<String,String>> mapsCol = new HashSet<Map<String,String>>();
for (int i=0; i < myArrayList.size(); i++) {
mapsCol.add((HashMap<String, String>)myArrayList.get(i));
View Config File and Rolling File Appender
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
<Console name="console" target="SYSTEM_OUT">
pattern="[%-5level] %d{yyyyMMdd-HHmmss} [%t] %M- %msg%n" />
<RollingFile name="rollingfile" fileName="C:\Users\user\git2\SMedia\logs\smtrace.log"
View Logging Levels
OFF No logging
FATAL Severe errors
ERROR non-fatal errors
WARN misc warnings
INFO runtime events
DEBUG Detailed info
TRACE Most detailed
View Using Logger
@BeforeClass //run once before each testsuite
public static void setUpClass() throws Exception {
gLogger = createLogger();
public void testDemo() throws Exception {"Starting the actual new testDemo. Waiting a few seconds.");
View Create Logger code
public static Logger createLogger() {
Logger aLogger = LogManager.getRootLogger();
aLogger.debug("\n" + "Inside createLogger - Logger is being set up. New test setup beginning.");
verificationErrors = new StringBuffer();"Logger has been set up.");
return aLogger;
protected static void createLogFile (FirefoxProfile fp) throws Exception {
File outfile = new File(outfileName);
View Imports
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
View Log4j2 Maven Dependencies
You can’t perform that action at this time.