jshell> String mytest1 = "this is a string with no escape sequences"
mytest1 ==> "this is a string with no escape sequences"
jshell> String mytest2 = "this string has a \n line break"
mytest2 ==> "this string has a \n line break"
jshell> Collections.disjoint(Arrays.asList(mytest1.split("")), Arrays.asList("\n"))
$21 ==> true
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
set row=0 | |
set inFile=merged.csv | |
set outFile=final.csv | |
if exist "%outFile%" del "%outFile%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedInputStream; | |
import java.io.FileInputStream; | |
import java.io.InputStream; | |
import java.io.IOException; | |
// NOTE: adapted from http://bit.ly/2LOQwIP | |
public class CountLines { | |
// private constructor in utility class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class SimplestCSVParser { | |
// private constructor -- utility class | |
private SimplestCSVParser(){} | |
// where the magic happens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.io.RandomAccessFile; | |
import org.apache.poi.ss.usermodel.Cell; | |
import org.apache.poi.ss.usermodel.DataFormatter; | |
import org.apache.poi.ss.usermodel.FormulaEvaluator; | |
import org.apache.poi.ss.usermodel.Row; | |
import org.apache.poi.ss.usermodel.Sheet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.util.Properties; | |
// Compile and then run! Change the settings.conf file and rerun without recompiling! | |
// Settings are updated without needing to recompile. | |
public class Settings { | |
public static boolean DEBUG = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.FileInputStream; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
public class Entries { | |
public static void main (String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class Signature { | |
public static void main(String[] args) { | |
// slightly more complex example to show off capabilities of method | |
String oldSignature = "synchronized static final native public void barFooer(int foo, double bar)"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import itertools | |
# number of primes to generate, beginning with 2, 3, 5, ... | |
N = 100 | |
def firstNPrimes(N): | |
primes = [2] | |
prime = (x for x in itertools.count(2) if not any ([x%y==0 for y in range(2, int(math.ceil(math.sqrt(x)))+1)])) | |
for n in range(1, int(math.ceil(N))): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.IOException; | |
import java.util.Arrays; | |
import java.util.Optional; | |
public class ParseFileName { | |
public static void main (String[] args) { | |
System.out.println(Arrays.toString(parseFileName("test").get())); | |
System.out.println(Arrays.toString(parseFileName("test.a").get())); |