<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (1.8.0_171) on Fri May 25 11:54:49 EDT 2018 --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Utilities (SelekTOR Java Documentation)</title> <meta name="date" content="2018-05-25"> <link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style"> <script type="text/javascript" src="../script.js"></script> </head> <body> <script type="text/javascript"><!-- try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Utilities (SelekTOR Java Documentation)"; } } catch(err) { } //--> var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9,"i15":9}; var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; var tableTab = "tableTab"; var activeTableTab = "activeTableTab"; </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/Utilities.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../deprecated-list.html">Deprecated</a></li> <li><a href="../index-files/index-1.html">Index</a></li> <li><a href="../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../lib/TrayPopupMenu.html" title="class in lib"><span class="typeNameLink">Prev Class</span></a></li> <li>Next Class</li> </ul> <ul class="navList"> <li><a href="../index.html?lib/Utilities.html" target="_top">Frames</a></li> <li><a href="Utilities.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <div> <ul class="subNavList"> <li>Summary: </li> <li>Nested | </li> <li>Field | </li> <li><a href="#constructor.summary">Constr</a> | </li> <li><a href="#method.summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail: </li> <li>Field | </li> <li><a href="#constructor.detail">Constr</a> | </li> <li><a href="#method.detail">Method</a></li> </ul> </div> <a name="skip.navbar.top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <!-- ======== START OF CLASS DATA ======== --> <div class="header"> <div class="subTitle">lib</div> <h2 title="Class Utilities" class="title">Class Utilities</h2> </div> <div class="contentContainer"> <ul class="inheritance"> <li>java.lang.Object</li> <li> <ul class="inheritance"> <li>lib.Utilities</li> </ul> </li> </ul> <div class="description"> <ul class="blockList"> <li class="blockList"> <hr> <br> <pre>public final class <span class="typeNameLabel">Utilities</span> extends java.lang.Object</pre> <dl> <dt><span class="simpleTagLabel">Author:</span></dt> <dd>Alistair Neil <info@dazzleships.net></dd> </dl> </li> </ul> </div> <div class="summary"> <ul class="blockList"> <li class="blockList"> <!-- ======== CONSTRUCTOR SUMMARY ======== --> <ul class="blockList"> <li class="blockList"><a name="constructor.summary"> <!-- --> </a> <h3>Constructor Summary</h3> <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> <caption><span>Constructors</span><span class="tabEnd"> </span></caption> <tr> <th class="colOne" scope="col">Constructor and Description</th> </tr> <tr class="altColor"> <td class="colOne"><code><span class="memberNameLink"><a href="../lib/Utilities.html#Utilities--">Utilities</a></span>()</code> <div class="block">Constructor</div> </td> </tr> </table> </li> </ul> <!-- ========== METHOD SUMMARY =========== --> <ul class="blockList"> <li class="blockList"><a name="method.summary"> <!-- --> </a> <h3>Method Summary</h3> <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr id="i0" class="altColor"> <td class="colFirst"><code>static void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#adjustTableColumnWidth-javax.swing.JTable-java.lang.String...-">adjustTableColumnWidth</a></span>(javax.swing.JTable table, java.lang.String... test)</code> <div class="block">Adjust specified column width based on the width of a test string</div> </td> </tr> <tr id="i1" class="rowColor"> <td class="colFirst"><code>static void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#editFile-java.lang.String-">editFile</a></span>(java.lang.String path)</code> <div class="block">Open the desktop default file editor</div> </td> </tr> <tr id="i2" class="altColor"> <td class="colFirst"><code>static java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#generateSecretKey-int-">generateSecretKey</a></span>(int length)</code> <div class="block">Generate secret key.</div> </td> </tr> <tr id="i3" class="rowColor"> <td class="colFirst"><code>static java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#getListAsCSV-java.util.ArrayList-">getListAsCSV</a></span>(java.util.ArrayList<java.lang.String> al)</code> <div class="block">Covert list to csv</div> </td> </tr> <tr id="i4" class="altColor"> <td class="colFirst"><code>static java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#getSha1Sum-java.lang.String-">getSha1Sum</a></span>(java.lang.String filepath)</code> <div class="block">Calculate the sha1 checksum of a given file</div> </td> </tr> <tr id="i5" class="rowColor"> <td class="colFirst"><code>static java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#getSHAHash-java.lang.String-">getSHAHash</a></span>(java.lang.String password)</code> <div class="block">Get SHAHash using given password string</div> </td> </tr> <tr id="i6" class="altColor"> <td class="colFirst"><code>static java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#getTextFromFile-java.lang.String-">getTextFromFile</a></span>(java.lang.String filepath)</code> <div class="block">Retrieve text from a text file</div> </td> </tr> <tr id="i7" class="rowColor"> <td class="colFirst"><code>static java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#getTextFromResource-java.lang.String-">getTextFromResource</a></span>(java.lang.String resourcepath)</code> <div class="block">Retrieve text from a resource text file</div> </td> </tr> <tr id="i8" class="altColor"> <td class="colFirst"><code>static java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#getTorHashPassword-java.lang.String-">getTorHashPassword</a></span>(java.lang.String secret)</code> </td> </tr> <tr id="i9" class="rowColor"> <td class="colFirst"><code>static boolean</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#isNewerVersion-java.lang.String-java.lang.String-">isNewerVersion</a></span>(java.lang.String localversion, java.lang.String remoteversion)</code> <div class="block">Check for newer appversion</div> </td> </tr> <tr id="i10" class="altColor"> <td class="colFirst"><code>static void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#loadUIStyle-java.lang.String-">loadUIStyle</a></span>(java.lang.String theme)</code> <div class="block">Initialises the UI Look and Feel</div> </td> </tr> <tr id="i11" class="rowColor"> <td class="colFirst"><code>static java.lang.String</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#openFileChooser-java.awt.Frame-java.lang.String-javax.swing.filechooser.FileFilter-int-">openFileChooser</a></span>(java.awt.Frame parent, java.lang.String folder, javax.swing.filechooser.FileFilter filter, int mode)</code> <div class="block">Opens java file chooser dialog, convenience method.</div> </td> </tr> <tr id="i12" class="altColor"> <td class="colFirst"><code>static boolean</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#openFileExternally-java.lang.String-">openFileExternally</a></span>(java.lang.String strUrl)</code> <div class="block">Launch the desktops default file handling program</div> </td> </tr> <tr id="i13" class="rowColor"> <td class="colFirst"><code>static void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#preloadFileChooser--">preloadFileChooser</a></span>()</code> <div class="block">Preloads filechooser in background so it will open instantly when requested</div> </td> </tr> <tr id="i14" class="altColor"> <td class="colFirst"><code>static void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#registerWindow--">registerWindow</a></span>()</code> <div class="block">Creates a hidden dummy window for registration to various docks/launchers Fixes the neverending launching indicator</div> </td> </tr> <tr id="i15" class="rowColor"> <td class="colFirst"><code>static byte[]</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../lib/Utilities.html#S2KRFC2440-java.lang.String-">S2KRFC2440</a></span>(java.lang.String secret)</code> <div class="block">Secret to key, Algorithm info taken from http://sunsite.icm.edu.pl/gnupg/rfc2440-3.html</div> </td> </tr> </table> <ul class="blockList"> <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> <!-- --> </a> <h3>Methods inherited from class java.lang.Object</h3> <code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li> </ul> </li> </ul> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <!-- ========= CONSTRUCTOR DETAIL ======== --> <ul class="blockList"> <li class="blockList"><a name="constructor.detail"> <!-- --> </a> <h3>Constructor Detail</h3> <a name="Utilities--"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>Utilities</h4> <pre>public Utilities()</pre> <div class="block">Constructor</div> </li> </ul> </li> </ul> <!-- ============ METHOD DETAIL ========== --> <ul class="blockList"> <li class="blockList"><a name="method.detail"> <!-- --> </a> <h3>Method Detail</h3> <a name="getListAsCSV-java.util.ArrayList-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>getListAsCSV</h4> <pre>public static java.lang.String getListAsCSV(java.util.ArrayList<java.lang.String> al)</pre> <div class="block">Covert list to csv</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>al</code> - </dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>String of comma separated values</dd> </dl> </li> </ul> <a name="preloadFileChooser--"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>preloadFileChooser</h4> <pre>public static void preloadFileChooser()</pre> <div class="block">Preloads filechooser in background so it will open instantly when requested</div> </li> </ul> <a name="openFileChooser-java.awt.Frame-java.lang.String-javax.swing.filechooser.FileFilter-int-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>openFileChooser</h4> <pre>public static java.lang.String openFileChooser(java.awt.Frame parent, java.lang.String folder, javax.swing.filechooser.FileFilter filter, int mode)</pre> <div class="block">Opens java file chooser dialog, convenience method. Returns filepath if successful and null if not</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>parent</code> - </dd> <dd><code>folder</code> - </dd> <dd><code>filter</code> - Extension filter</dd> <dd><code>mode</code> - Fileselection mode</dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>String Filepath</dd> </dl> </li> </ul> <a name="isNewerVersion-java.lang.String-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>isNewerVersion</h4> <pre>public static boolean isNewerVersion(java.lang.String localversion, java.lang.String remoteversion)</pre> <div class="block">Check for newer appversion</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>localversion</code> - </dd> <dd><code>remoteversion</code> - </dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>True if newer</dd> </dl> </li> </ul> <a name="editFile-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>editFile</h4> <pre>public static void editFile(java.lang.String path)</pre> <div class="block">Open the desktop default file editor</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>path</code> - Path to file</dd> </dl> </li> </ul> <a name="openFileExternally-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>openFileExternally</h4> <pre>public static boolean openFileExternally(java.lang.String strUrl)</pre> <div class="block">Launch the desktops default file handling program</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>strUrl</code> - </dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>Returns true if successful</dd> </dl> </li> </ul> <a name="loadUIStyle-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>loadUIStyle</h4> <pre>public static void loadUIStyle(java.lang.String theme)</pre> <div class="block">Initialises the UI Look and Feel</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>theme</code> - </dd> </dl> </li> </ul> <a name="adjustTableColumnWidth-javax.swing.JTable-java.lang.String...-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>adjustTableColumnWidth</h4> <pre>public static void adjustTableColumnWidth(javax.swing.JTable table, java.lang.String... test)</pre> <div class="block">Adjust specified column width based on the width of a test string</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>table</code> - </dd> <dd><code>test</code> - </dd> </dl> </li> </ul> <a name="generateSecretKey-int-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>generateSecretKey</h4> <pre>public static java.lang.String generateSecretKey(int length)</pre> <div class="block">Generate secret key.</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>length</code> - </dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>String key</dd> </dl> </li> </ul> <a name="getTorHashPassword-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>getTorHashPassword</h4> <pre>public static java.lang.String getTorHashPassword(java.lang.String secret)</pre> </li> </ul> <a name="S2KRFC2440-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>S2KRFC2440</h4> <pre>public static byte[] S2KRFC2440(java.lang.String secret)</pre> <div class="block">Secret to key, Algorithm info taken from http://sunsite.icm.edu.pl/gnupg/rfc2440-3.html</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>secret</code> - </dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>hashed key for the given secret</dd> </dl> </li> </ul> <a name="getSHAHash-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>getSHAHash</h4> <pre>public static java.lang.String getSHAHash(java.lang.String password)</pre> <div class="block">Get SHAHash using given password string</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>password</code> - </dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>SHAhash string</dd> </dl> </li> </ul> <a name="getTextFromResource-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>getTextFromResource</h4> <pre>public static java.lang.String getTextFromResource(java.lang.String resourcepath)</pre> <div class="block">Retrieve text from a resource text file</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>resourcepath</code> - </dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>String text</dd> </dl> </li> </ul> <a name="getTextFromFile-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>getTextFromFile</h4> <pre>public static java.lang.String getTextFromFile(java.lang.String filepath)</pre> <div class="block">Retrieve text from a text file</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>filepath</code> - </dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>String text</dd> </dl> </li> </ul> <a name="getSha1Sum-java.lang.String-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>getSha1Sum</h4> <pre>public static java.lang.String getSha1Sum(java.lang.String filepath)</pre> <div class="block">Calculate the sha1 checksum of a given file</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>filepath</code> - </dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>Checksum as a hex string</dd> </dl> </li> </ul> <a name="registerWindow--"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>registerWindow</h4> <pre>public static void registerWindow()</pre> <div class="block">Creates a hidden dummy window for registration to various docks/launchers Fixes the neverending launching indicator</div> </li> </ul> </li> </ul> </li> </ul> </div> </div> <!-- ========= END OF CLASS DATA ========= --> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/Utilities.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../deprecated-list.html">Deprecated</a></li> <li><a href="../index-files/index-1.html">Index</a></li> <li><a href="../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../lib/TrayPopupMenu.html" title="class in lib"><span class="typeNameLink">Prev Class</span></a></li> <li>Next Class</li> </ul> <ul class="navList"> <li><a href="../index.html?lib/Utilities.html" target="_top">Frames</a></li> <li><a href="Utilities.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <div> <ul class="subNavList"> <li>Summary: </li> <li>Nested | </li> <li>Field | </li> <li><a href="#constructor.summary">Constr</a> | </li> <li><a href="#method.summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail: </li> <li>Field | </li> <li><a href="#constructor.detail">Constr</a> | </li> <li><a href="#method.detail">Method</a></li> </ul> </div> <a name="skip.navbar.bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>