- 1
- 2
- 3
- 4
- 5
- 6
- 7
private static class Errors extends ArrayList<String> {
private static final long serialVersionUID = 1L;
}
private static class Notices extends ArrayList<String> {
private static final long serialVersionUID = 1L;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+73
private static class Errors extends ArrayList<String> {
private static final long serialVersionUID = 1L;
}
private static class Notices extends ArrayList<String> {
private static final long serialVersionUID = 1L;
}
две большие разницы
+73
private void CopyFiles(String dirName) {
InputStream is = this.getClass().getResourceAsStream(
"/18.xslt");
OutputStream os;
try {
os = new FileOutputStream(dirName + "/18.xslt");
byte[] buffer = new byte[4096];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.close();
is.close();
is = this.getClass().getResourceAsStream(
"/13_02.tif");
os = new FileOutputStream(dirName + "/13_02.tif");
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.close();
is.close();
is = this.getClass().getResourceAsStream("/13_02.xslt");
os = new FileOutputStream(dirName + "/13_02.xslt");
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.close();
is.close();
is = this.getClass().getResourceAsStream(
"/13_02_t.tif");
os = new FileOutputStream(dirName + "/13_02_t.tif");
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.close();
is.close();
is = this.getClass().getResourceAsStream(
"/13_02_t.xslt");
os = new FileOutputStream(dirName + "/13_02_t.xslt");
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.close();
is.close();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
+73
private boolean isAuthorized( ExecutionResult result )
{
Iterator<Long> accessCountIterator = result.columnAs( "accessCount" );
while ( accessCountIterator.hasNext() )
{
if (accessCountIterator.next() > 0L)
{
return true;
}
}
return false;
}
Человек написал книжку по програмированию :(
isbn:1449356265/9781449356262
+73
final double[][] matrix = new double[companies.size() + 1][(sampleSizeTo - sampleSizeFrom) / sampleSizeStep + 2];
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[0].length; j++) {
if (i == 0 && j == 0) {
continue;
}
if (i == 0) {
matrix[i][j] = sampleSizeFrom + (j - 1) * sampleSizeStep;
continue;
}
if (j == 0) {
matrix[i][j] = companies.get(i-1);
continue;
}
}
}
Название функции getSmartDistibution (именно так) какбэ намекает, что дальше будет весело
+73
class MyException extends Exception {
/* конструкторы, геттеры-сеттеры и прочее-прочее */
public void handle() { /* over 9000 строк */ }
}
class MyClass {
public void myMethod() {
try { /* ... */ }
catch (MyException e) {
e.handle();
}
}
}
исключение, которое обрабатывает, можно сказать, само себя, бред?
+73
public enum Action {
ADD, DELETE, UPDATE, REFRESH;
public static Action getEnum(String value) {
for (Action current : values()) {
if (current.name().equalsIgnoreCase(value)) {
return current;
}
}
throw new IllegalArgumentException("Unknown input value. Input value is '" + value + "'");
}
@Override
public String toString() {
return this.name().toLowerCase();
}
}
public enum Manager {
USER, ROLE, SERVICE;
public static Manager getEnum(String value) {
for (Manager current : values()) {
if (current.name().equalsIgnoreCase(value)) {
return current;
}
}
throw new IllegalArgumentException("Unknown input value. Input value is '" + value + "'");
}
@Override
public String toString() {
return this.name().toLowerCase();
}
public boolean isUser() {
return this == USER;
}
public boolean isRole() {
return this == ROLE;
}
public boolean isService() {
return this == SERVICE ;
}
}
public class StringToEnumConverterFactory implements ConverterFactory<String, Enum> {
@Override
public <T extends Enum> Converter<String, T> getConverter(Class<T> targetType) {
return new StringToEnumConverter<T>(targetType);
}
private final class StringToEnumConverter<T extends Enum> implements Converter<String, T> {
private Class<T> enumType;
private StringToEnumConverter(Class<T> enumType) {
this.enumType = enumType;
}
@Override
public T convert(String source) {
if (enumType.getName().equalsIgnoreCase("com.finder.enumerator.manager")) {
return (T) Manager.getEnum(source);
}
if (enumType.getName().equalsIgnoreCase("com.finder.enumerator.action")) {
return (T) Action.getEnum(source);
}
return (T) Enum.valueOf(this.enumType, source);
}
}
}
/* -- Mapping -- */
@RequestMapping(value = "manage/index/{manager}/{action}", method = RequestMethod.GET)
public String addValueToEntity(@PathVariable("manager") Manager manager, @PathVariable("action") Action action) {
...
@RequestMapping(value = "/manage/index", method = RequestMethod.GET)
public String indexPage(ModelMap model, @RequestParam(value = "manager", required = true) Manager manager) {
...
Spring MVC. Проблема в том что строка lovercase а значения Enum-ов uppercase
+73
GZIPOutputStream out = new GZIPOutputStream(out) {
{
def.setLevel(Deflater.BEST_COMPRESSION);
}
};
Вот так можно выставить максимальную степень сжатия GZIP-потока в жабе.
+73
int k = 0;
for (int i = 1; i<=str.length(); i++){
k = i;
}
System.out.println("dlina: "+k);
Счётчик длины строки....
+73
String format = String.format("%%0%dd", 2); // format = "%02d";
String seconds = String.format(format, milTime % 60);
+73
Дорогой участник! Не спеши покидать страницу. Я прошу тебя помочь:
не поленись, пройдись по всем постам, и поставь каждому участнику по минусу;
минусуя других участников ты воспитываешь в себе чувство меры и помогаешь обществу снижать ЧСВ.
Заранее спасибо, друг мой. Ты будешь вознагражден за это деяние!
Тот, кто покинул страницу, но не выполнил моей просьбы, умрет через 9 дней.
Дорогой участник! Не спеши покидать страницу. Я прошу тебя помочь:
не поленись, пройдись по всем постам, и поставь каждому участнику по минусу;
минусуя других участников ты воспитываешь в себе чувство меры и помогаешь обществу снижать ЧСВ.
Заранее спасибо, друг мой. Ты будешь вознагражден за это деяние!
Тот, кто покинул страницу, но не выполнил моей просьбы, умрет через 9 дней.