public class Util
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
forbiddenCharacters
Forbidden characters in file names.
|
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
color2Hex(java.awt.Color color)
Converts a color to hex format for use in HTML tags.
|
static boolean |
containsForbiddenCharacter(java.lang.String string)
Indicates whether a string contains characters forbidden in file names.
|
static void |
copyFile(java.io.File in,
java.io.File out)
Copy the content of one file to another.
|
static boolean |
deleteDir(java.io.File dir)
Deletes all files and subdirectories under dir.
|
static java.lang.String |
getExtension(java.io.File file)
Returns the extensions of a file.
|
static java.lang.String |
getFileName(java.io.File file)
An OS independent getName alternative.
|
static java.lang.String |
getFileName(java.lang.String filePath)
An OS independent getName alternative.
|
static int |
getNumberOfLines(java.io.File file)
Returns the number of lines in the given file.
|
static double |
getPpmError(double theoreticalMzValue,
double massError)
Returns the ppm value of the given mass error relative to its theoretical
m/z value.
|
static java.io.File |
getUserSelectedFile(java.awt.Component parent,
java.lang.String aFileEnding,
java.lang.String aFileFormatDescription,
java.lang.String aDialogTitle,
java.lang.String lastSelectedFolder,
boolean openDialog)
Returns the file selected by the user, or null if no file was selected.
|
static java.lang.String |
removeExtension(java.lang.String fileName)
Removes the extension from a file name or path.
|
static java.lang.String |
removeForbiddenCharacters(java.lang.String string)
Removes the forbidden characters from a string
|
static double |
roundDouble(double d,
int places)
Rounds a double value to the wanted number of decimal places.
|
static boolean |
sameLists(java.util.ArrayList<java.lang.Integer> list1,
java.util.ArrayList<java.lang.Integer> list2)
Convenience methods indicating whether the content of two lists have the
same content.
|
static void |
tableToFile(javax.swing.JTable table,
java.lang.String separator,
ProgressDialogX progressDialog,
boolean removeHtml,
java.io.BufferedWriter writer)
Writes the table to a file as separated text.
|
static java.lang.String |
tableToText(javax.swing.JTable table,
java.lang.String separator,
ProgressDialogX progressDialog,
boolean removeHtml)
Returns the table as a separated text file.
|
public static final java.lang.String[] forbiddenCharacters
public static java.lang.String removeForbiddenCharacters(java.lang.String string)
string
- the string of interestpublic static boolean containsForbiddenCharacter(java.lang.String string)
string
- the string of interestpublic static double roundDouble(double d, int places)
d
- the double to round ofplaces
- number of decimal places wantedpublic static boolean deleteDir(java.io.File dir)
dir
- public static double getPpmError(double theoreticalMzValue, double massError)
theoreticalMzValue
- the theoretical massmassError
- the mass errorpublic static java.lang.String color2Hex(java.awt.Color color)
color
- the color to convertpublic static java.lang.String getFileName(java.lang.String filePath)
filePath
- the file path as a stringpublic static java.lang.String getFileName(java.io.File file)
file
- the filepublic static java.lang.String getExtension(java.io.File file)
file
- the filepublic static java.lang.String removeExtension(java.lang.String fileName)
fileName
- the file namepublic static java.io.File getUserSelectedFile(java.awt.Component parent, java.lang.String aFileEnding, java.lang.String aFileFormatDescription, java.lang.String aDialogTitle, java.lang.String lastSelectedFolder, boolean openDialog)
parent
- the parent dialog or frameaFileEnding
- the file type, e.g., .txtaFileFormatDescription
- the file format description, e.g., (Mascot
Generic Format) *.mgfaDialogTitle
- the title for the dialoglastSelectedFolder
- the last selected folderopenDialog
- if true an open dialog is shown, false results in a
save dialogpublic static java.lang.String tableToText(javax.swing.JTable table, java.lang.String separator, ProgressDialogX progressDialog, boolean removeHtml)
table
- the table to turn in to textseparator
- the text separatorprogressDialog
- the progress dialogremoveHtml
- if true, html is converted to textpublic static void tableToFile(javax.swing.JTable table, java.lang.String separator, ProgressDialogX progressDialog, boolean removeHtml, java.io.BufferedWriter writer) throws java.io.IOException
table
- the table to write to fileseparator
- the text separatorprogressDialog
- the progress dialogremoveHtml
- if true, html is converted to textwriter
- the writer where the file is to be writtenjava.io.IOException
public static void copyFile(java.io.File in, java.io.File out) throws java.io.IOException
in
- the file to copy fromout
- the file to copy tojava.io.IOException
public static int getNumberOfLines(java.io.File file) throws java.io.IOException
file
- the file to find the number of lines injava.io.IOException
public static boolean sameLists(java.util.ArrayList<java.lang.Integer> list1, java.util.ArrayList<java.lang.Integer> list2)
list1
- the first listlist2
- the second listCopyright © 2013. All Rights Reserved.