How to loop through Collection
To loop through a collection in java we have 2 options:1. loop using iterator: Iterator<string> iterator = myCollection.iterator(); while (iterator.hasNext()) { …
To loop through a collection in java we have 2 options:1. loop using iterator: Iterator<string> iterator = myCollection.iterator(); while (iterator.hasNext()) { …
This program simulates a year of euromillions-alike game of luck. Each year it is assumed that it has 121 lotteries and it is assumed that the number of players per…
The birthday paradox claims that if there are 23 people in the same room, then the chance 2 of them to have birthday on the same day is 50%.The following…
An easy piece of code to write to a file: BufferedWriter out = new BufferedWriter (new OutputStreamWriter(new FileOutputStream("c:\\LOGS\\MyParameter.txt"),"UTF-8")); out.write("parameter: " + parameter); …
Here is a code to call ping command on windows using java. The question would be, why not to ping directly from ms-dos window? :)The answer is because this application…
The following piece of code is an example of extraction of specific attribute from an xml file.The xml looks like this:<?xml version="1.0" ?><xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xft-xliff="http://www.xfa.org/schema/xfa-xliff/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd"><file…
Please, view the following related article:Oracle DB: XPath: Extract part of xml
Here is a piece of java code, which fetches data from SYS_REFCURSOR, using the OracleTypes.CURSOR argument type:import java.sql.*;import java.util.Date;import oracle.jdbc.OracleTypes;public class ListCountries { static Driver driver; static Connection conn =…
The program below reads xml files from specific directory, extracts a value out of each one of them using XPath expression, puts the value side by side with a substring…
If our java program runs in an already connected environment, it is not necessary to open a new connection with jdbc.It is just enough to use jdbc:default:connection string. This is…