Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;

public class Main {
    /**
     * Gets the opf file name.
     * 
     * @param path the folder contains file opf.
     * @return the opf file name
     */
    public static String getOpfFileName(String path) {
        String fileName = null;
        File folder = new File(path);
        if (folder.isDirectory()) {
            File[] listOfFiles = folder.listFiles();
            if (listOfFiles != null) {
                for (File file : listOfFiles) {
                    if (file.isFile() && file.getName().endsWith(".opf")) {
                        fileName = file.getName();
                        break;
                    }
                }
            }
        }
        return fileName;
    }
}