bdsup2sub.utils.ToolBox Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2014 Volker Oth (0xdeadbeef) / Miklos Juhasz (mjuhasz)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package bdsup2sub.utils;
import bdsup2sub.tools.JFileFilter;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileInputStream;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.List;
import java.util.Locale;
public final class ToolBox {
private static final DecimalFormat FPS_FORMATTER = new DecimalFormat("##.###", DecimalFormatSymbols.getInstance(Locale.US));
public static String leftZeroPad(int value, int width) {
return String.format("%0" + width + "d", value);
}
public static String toHexLeftZeroPadded(long value, int width) {
return String.format("0x%0" + width + "x", value);
}
public static String formatDouble(double value) {
return FPS_FORMATTER.format(value);
}
/**
* Write ASCII string to buffer[index] (no special handling for multi-byte characters)
* @param buffer Byte array
* @param index Index to write to
* @param s String containing ASCII characters
* @throws ArrayIndexOutOfBoundsException
*/
public static void setString(byte buffer[], int index, String s) {
for (int i =0; i";
if (ex.getMessage() != null) {
m += ex.getMessage() + "";
}
StackTraceElement ste[] = ex.getStackTrace();
for (StackTraceElement e : ste) {
m += e.toString() + "
";
}
m += "