小编Se *_*ong的帖子

Java文件存在区分大小写的.jpg和.JPG

我使用此函数来检测我的文件是否存在.虽然我有一些图像存储为.jpg,.JPG,.png和.PNG.但即使真实文件具有扩展名.JPG或.PNG,它也总是返回.jpg或.png为真.

在我将其呈现到我的网页后,它会抛出错误"无法加载资源:服务器响应状态为404(未找到)".

public static String getPhotoFileExtension(int empKey){
    try{
        String[] types = {".jpg",".JPG",".png", ".PNG"};
        for(String t : types)
        {
            String path = "/"+Common.PHOTO_PATH + empKey + t;
            File f = new File(Sessions.getCurrent().getWebApp()
                    .getRealPath(path));
            if(f.isFile()) 
                return t;
        }
    }catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}
Run Code Online (Sandbox Code Playgroud)

java

20
推荐指数
2
解决办法
7836
查看次数

Postgresql序列与串行

我想知道何时选择序列更好,何时使用串口更好.

我想要的是在插入后使用返回最后一个值

SELECT LASTVAL();
Run Code Online (Sandbox Code Playgroud)

我读了这个问题 PostgreSQL Autoincrement

我从来没有使用过串口.

sql postgresql

18
推荐指数
2
解决办法
2万
查看次数

java多态和继承问题

首先,我虽然java的多态函数是由它的参数实例类型映射的.

请有人帮忙解释为什么我的函数没有调用myFunction(EmployeeImpl emp)签名实例EmployeeImpl.

public class MainApp {
  public static void main(String[] args){
    Employee emp = new EmployeeImpl();
    emp.callMyFunction();
  }
}

abstract class Employee{
  public void callMyFunction(){
    //here is huge amount of code, which all child class has the same
    //excepted this line is called to a different function by it instant types.
    EmployeeFacade.myFunction(this);
  }
}
class EmployeeImpl extends Employee{

}
class EmployeeFacade{
  public static void myFunction(Employee emp){
    //same data to database
    System.out.println("Employee: "+ emp.getClass().getName());
  }
  public …
Run Code Online (Sandbox Code Playgroud)

java

0
推荐指数
1
解决办法
504
查看次数

标签 统计

java ×2

postgresql ×1

sql ×1