A class example where political science and IT meet. Listen to Dr. Peter Rizun’s 20 minute presentaties about the effects of SegWit in Bitcoin. Bitcoin is not just programming code. The network is used by rational actors -who sometimes behave irrational though, but in general try to maximize their profits. The rules of the game, in this case the incentives for miners are new coins after finding a block and transaction fees. Take a look at Satoshi’s white paper while listening, Rizun refers to section two. These incentives are decisive in making the miner’s choice how and what coin to mine.
Next we merge the two main class programs for the former post into a single application. After execution of this package paths, xml filenames and accompanying content are printed to our NetBeans console.
Earlier I recommended Java beginners to save the main programs in their Hello World project. It’s time to leave this one project approach. As a Java-for-testers beginners you better start a new project for every single problem you encounter. You can always copy the core of your solution to the package where you need it not ‘contaminating’ the project you are actually working on with maybe useless code. Which allows me referring Occam’s razor blade. Today his medieval approach is more useful to us as agile testers in stripping the ‘borrowed’ code than for instance ISQTB. Applying his blade probably gives you the leanest code you need to perform your job. Analysing xml files for example.
In my former post I provided the java code to search for xml-files in our logs- directory and write these filenames including their pathname to a text file named “FilteredLogFileList.txt” in the project directory. I also described how to create the logs-folder and fill it with files.
I use this setup as my starting point for the next step. Here we take a single well formatted xml-file and present it’s content in the NetBeans console. This is easier than you think. Java knows a lot of libraries to perform specific tasks and reading xml-files is one of them. If you used dummyXMLs you can use dummy2.xml in the rest of this post.
This post gives you the material to select or filter files in a directory. It is not a ‘real’ tutorial, but rather gives you means to play with the code with immediate results. By playing you get quicker understanding how things work. At least I do. The code filters xml-files, but by changing one line of code you can filter any extension you wish. After you ran the java program you end up having a text file containing the list of files which met your criteria. I do suppose you already have finished the HelloWorld.java part with succes. Otherwise finish this first. YouTube is full of HelloWorlds. You can use this project or create a new fresh one if you prefer.