Java tutorial
/* * Copyright (C) 2014 kyanai * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * aDouble with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.tao_harmony.fx2extend.journal; import com.orangesignal.csv.manager.CsvEntityManager; import java.io.File; import java.io.IOException; import java.util.List; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import com.orangesignal.csv.manager.CsvManager; /** * @author kyanai * */ public class JournalUtil { /** * ??.. */ public static final short FX2_FILLER = 0; /** * ??.999. */ public static final short FX2_SYSTEM_CLASS = (short) 999; /** * NULL?.. */ public static final String FX2_NULL = StringUtils.EMPTY; /** * ?????. * * @param journals * * @param fileName * ? * @throws NoListException * ?Null?????? * @throws FileNameEmptyException * ???Null?????? * @throws IOException * ??????? */ public static void saveJournals(List<Journal> journals, String fileName) throws NoListException, FileNameEmptyException, IOException { // Null? if (journals == null) { throw new NoListException(); } // ?? if (journals.isEmpty()) { throw new NoListException(); } // ???? if (StringUtils.isBlank(fileName) || StringUtils.isBlank(FilenameUtils.getName(fileName))) { throw new FileNameEmptyException(); } // ?.slp??? String name = FilenameUtils.getFullPath(fileName) + FilenameUtils.getBaseName(fileName) + ".slp"; // ? CsvManager csvManager = new CsvEntityManager(); //CsvManager csvManager = CsvManagerFactory.newCsvManager(); csvManager.save(journals, Journal.class).to(new File(name)); } /** * ?????. ?????????????????. * * @param journals * * @param specifications * * @param fileName * ? * @throws NoListException * ?Null?????? * @throws IOException * ??????? * @throws FileNameEmptyException * ???Null?????? */ public static void saveJournals(List<Journal> journals, List<DepartmentSpecification> specifications, String fileName) throws NoListException, IOException, FileNameEmptyException { // ???? saveJournals(journals, fileName); // ???? // ???.cls??? String name = FilenameUtils.getFullPath(fileName) + FilenameUtils.getBaseName(fileName) + ".cls"; CsvManager csvManager = new CsvEntityManager(); //CsvManager csvManager=CsvManagerFactory.newCsvManager(); csvManager.save(specifications, DepartmentSpecification.class).to(new File(name)); } }