📄 common.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: Common.java
package carven;
import java.io.*;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class Common
{
public Common()
{
}
public static String ReadFile(String filePath)
throws Exception
{
FileInputStream inStream = new FileInputStream(new File(filePath));
byte result[] = new byte[inStream.available()];
inStream.read(result);
inStream.close();
return new String(result);
}
public static void WriteFile(String inString, String fileName)
throws Exception
{
FileWriter receiveFile = new FileWriter(fileName);
receiveFile.write(inString);
receiveFile.close();
}
public static String getTime()
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date currentDate = Calendar.getInstance().getTime();
return formatter.format(currentDate);
}
public static String getTime(String format)
{
SimpleDateFormat formatter = new SimpleDateFormat(format);
java.util.Date currentDate = Calendar.getInstance().getTime();
return formatter.format(currentDate);
}
public static String getTime(String timeStr, String format)
throws Exception
{
SimpleDateFormat formatter = new SimpleDateFormat(format);
return formatter.format(formatter.parse(timeStr));
}
public static String[] SplitString(String source, String reg)
{
int tmp = -1;
int len;
for (len = 1; (tmp = source.indexOf(reg, tmp + 1)) > -1; len++);
String result[] = new String[len];
tmp = 0;
int tmp1 = 0;
for (int i = 0; i < len; i++)
{
tmp1 = source.indexOf(reg, tmp);
if (tmp1 < 0)
tmp1 = source.length();
result[i] = source.substring(tmp, tmp1);
tmp = tmp1 + 1;
}
return result;
}
public static String replaceAll(String sourceString, String oldString, String newString)
{
do
{
int pos0 = sourceString.indexOf(oldString);
if (pos0 == -1)
return sourceString;
String str1 = sourceString.substring(0, pos0);
String str2 = sourceString.substring(pos0 + oldString.length());
sourceString = str1 + newString + str2;
} while (true);
}
public static String SearchClassLocation(String className)
{
String cname = className;
if (!className.startsWith("/"))
className = "/" + className;
className = className.replace('.', '/');
className = className + ".class";
URL classUrl = null;
try
{
classUrl = Class.forName(cname).getResource(className);
}
catch (Exception e)
{
e.printStackTrace();
}
if (classUrl != null)
return classUrl.getFile();
else
return null;
}
public static int CompareTime(String time1, String time2, String timeFormat)
throws Exception
{
SimpleDateFormat dateFormat = new SimpleDateFormat(timeFormat);
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(dateFormat.parse(time1));
c2.setTime(dateFormat.parse(time2));
if (c1.after(c2))
return 1;
if (c1.equals(c2))
return 0;
return !c1.before(c2) ? 0 : -1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -