List of usage examples for org.apache.commons.io FilenameUtils removeExtension
public static String removeExtension(String filename)
From source file:net.sourceforge.atunes.kernel.modules.tags.PropertiesFileTagAdapter.java
private String getPropertiesFile(final ILocalAudioObject file) { return StringUtils.getString(FilenameUtils.removeExtension(file.getUrl()), ".properties"); }
From source file:com.sliit.neuralnetwork.RecurrentNN.java
private void loadSaveNN(String name, boolean save) { System.out.println("recNN loadSaveNN"); File directory = new File(uploadDirectory); File[] allNN = directory.listFiles(); boolean status = false; try {/*from ww w . ja v a2 s. c o m*/ if (model == null && save) { buildModel(); } if (allNN != null && allNN.length > 0) { for (File NN : allNN) { String fnme = FilenameUtils.removeExtension(NN.getName()); if (name.equals(fnme)) { status = true; if (save) { ModelSerializer.writeModel(model, NN, true); System.out.println("Model Saved With Weights Successfully"); } else { model = ModelSerializer.restoreMultiLayerNetwork(NN); } break; } } } if (!status && save) { //File tempFIle = File.createTempFile(name,".zip",directory); File tempFile = new File(directory.getAbsolutePath() + "/" + name + ".zip"); if (!tempFile.exists()) { tempFile.createNewFile(); } ModelSerializer.writeModel(model, tempFile, true); } } catch (IOException e) { System.out.println("Error occurred:" + e.getMessage()); } }
From source file:de.uzk.hki.da.core.IngestAreaNoBagitScannerWorker.java
private List<String> addToList(String sipname, String csn, long currentTimeStamp, List<String> childrenWhichAreReady) { if (!sips.containsKey(sipname)) { Job job = getJob(convertMaskedSlashes(FilenameUtils.removeExtension(sipname)), csn); if (job == null) { // consider only containers for which there is not already a job // in queue since it is possible that the CB has stopped and now resumes work. logger.debug("New file found, making timestamp for: " + sipname); sips.put(sipname, currentTimeStamp); } else {// w w w.j a v a 2 s . c om // USER EMAIL // System.out.println("ES gibt schon einen Job !!! " + job); } } else { long diff = currentTimeStamp - sips.get(sipname); logger.debug("Old file found, lets look how their timestamps differ: " + sipname + " diff: " + diff); if (diff > minAge) { logger.debug("File " + sipname + " which has lasted " + minAge + " miliseconds is ready."); sips.remove(sipname); childrenWhichAreReady.add(sipname); } } return childrenWhichAreReady; }
From source file:de.mprengemann.intellij.plugin.androidicons.forms.MaterialIconsImporter.java
private void fillAssets() { assetSpinner.removeAllItems();// w ww .ja va2s . co m if (this.assetRoot.getCanonicalPath() == null) { return; } File assetRoot = new File(this.assetRoot.getCanonicalPath()); assetRoot = new File(assetRoot, (String) categorySpinner.getSelectedItem()); assetRoot = new File(assetRoot, DEFAULT_RESOLUTION); final FilenameFilter drawableFileNameFiler = new FilenameFilter() { @Override public boolean accept(File file, String s) { if (!FilenameUtils.isExtension(s, "png")) { return false; } String filename = FilenameUtils.removeExtension(s); return filename.startsWith("ic_") && filename.endsWith("_black_48dp"); } }; File[] assets = assetRoot.listFiles(drawableFileNameFiler); if (assets == null) { return; } for (File asset : assets) { String assetName = FilenameUtils.removeExtension(asset.getName()); assetName = assetName.replace("_black_48dp", ""); assetName = assetName.replace("ic_", ""); assetSpinner.addItem(assetName); } }
From source file:de.petermoesenthin.alarming.util.FileUtil.java
public static String getMetaFilePath(String soundFilePath) { return FilenameUtils.removeExtension(soundFilePath) + "." + AUDIO_METADATA_FILE_EXTENSION; }
From source file:algorithm.QRCodeWatermarking.java
/** * This algorithm writes a QR-code image on a carrier image. * /* w w w .ja va 2s . c o m*/ * @param qrCodeFile * @param carrierFile * @param imageFormat * @return image file with qr code on top of carrier * @throws IOException */ private File writeQRCodeOnImage(File qrCodeFile, File carrierFile, String imageFormat) throws IOException { BufferedImage barcode = ImageIO.read(qrCodeFile); BufferedImage carrier = ImageIO.read(carrierFile); if (barcode.getWidth() > carrier.getWidth() || barcode.getHeight() > carrier.getHeight()) { displayMessage( "The QR-code is to big to add it to the carrier image. Try again with a lower QR-code size!"); qrCodeFile.delete(); return null; } Graphics graphics = carrier.getGraphics(); graphics.drawImage(barcode, getXPosition(), getYPosition(), null); String outputFileName = FilenameUtils.removeExtension(getOutputFileName(carrierFile)) + "." + imageFormat; File outputFile = new File(outputFileName); ImageIO.write(carrier, imageFormat, outputFile); qrCodeFile.delete(); return outputFile; }
From source file:ch.kostceco.tools.kostsimy.KOSTSimy.java
/** Die Eingabe besteht aus 2 Parameter: [0] Original-Ordner [1] Replica-Ordner * /*from w w w . ja v a 2 s .c om*/ * @param args * @throws IOException */ public static void main(String[] args) throws IOException { ApplicationContext context = new ClassPathXmlApplicationContext("classpath:config/applicationContext.xml"); // Zeitstempel Start java.util.Date nowStart = new java.util.Date(); java.text.SimpleDateFormat sdfStart = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); String ausgabeStart = sdfStart.format(nowStart); KOSTSimy kostsimy = (KOSTSimy) context.getBean("kostsimy"); File configFile = new File("configuration" + File.separator + "kostsimy.conf.xml"); // Ueberprfung des Parameters (Log-Verzeichnis) String pathToLogfile = kostsimy.getConfigurationService().getPathToLogfile(); File directoryOfLogfile = new File(pathToLogfile); if (!directoryOfLogfile.exists()) { directoryOfLogfile.mkdir(); } // Im Logverzeichnis besteht kein Schreibrecht if (!directoryOfLogfile.canWrite()) { System.out.println( kostsimy.getTextResourceService().getText(ERROR_LOGDIRECTORY_NOTWRITABLE, directoryOfLogfile)); System.exit(1); } if (!directoryOfLogfile.isDirectory()) { System.out.println(kostsimy.getTextResourceService().getText(ERROR_LOGDIRECTORY_NODIRECTORY)); System.exit(1); } // Ist die Anzahl Parameter (2) korrekt? if (args.length > 3) { System.out.println(kostsimy.getTextResourceService().getText(ERROR_PARAMETER_USAGE)); System.exit(1); } File origDir = new File(args[0]); File repDir = new File(args[1]); File logDatei = null; logDatei = origDir; // Informationen zum Arbeitsverzeichnis holen String pathToWorkDir = kostsimy.getConfigurationService().getPathToWorkDir(); /* Nicht vergessen in "src/main/resources/config/applicationContext-services.xml" beim * entsprechenden Modul die property anzugeben: <property name="configurationService" * ref="configurationService" /> */ // Konfiguration des Loggings, ein File Logger wird zustzlich erstellt LogConfigurator logConfigurator = (LogConfigurator) context.getBean("logconfigurator"); String logFileName = logConfigurator.configure(directoryOfLogfile.getAbsolutePath(), logDatei.getName()); File logFile = new File(logFileName); // Ab hier kann ins log geschrieben werden... LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_HEADER)); LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_START, ausgabeStart)); LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_END)); LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_INFO)); System.out.println("KOST-Simy"); System.out.println(""); if (!origDir.exists()) { // Das Original-Verzeichnis existiert nicht LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_NOORIGDIR, origDir.getAbsolutePath()))); System.out .println(kostsimy.getTextResourceService().getText(ERROR_NOORIGDIR, origDir.getAbsolutePath())); System.exit(1); } if (!repDir.exists()) { // Das Replica-Verzeichnis existiert nicht LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_NOREPDIR1, repDir.getAbsolutePath()))); System.out .println(kostsimy.getTextResourceService().getText(ERROR_NOREPDIR1, repDir.getAbsolutePath())); System.exit(1); } File xslOrig = new File("resources" + File.separator + "kost-simy.xsl"); File xslCopy = new File(directoryOfLogfile.getAbsolutePath() + File.separator + "kost-simy.xsl"); if (!xslCopy.exists()) { Util.copyFile(xslOrig, xslCopy); } // Informationen zur prozentualen Stichprobe holen String randomTest = kostsimy.getConfigurationService().getRandomTest(); /* Nicht vergessen in "src/main/resources/config/applicationContext-services.xml" beim * entsprechenden Modul die property anzugeben: <property name="configurationService" * ref="configurationService" /> */ int iRandomTest = 100; try { iRandomTest = Integer.parseInt(randomTest); } catch (Exception ex) { // unzulaessige Eingabe --> 50 wird gesetzt iRandomTest = 50; } if (iRandomTest > 100 || iRandomTest < 1) { // unzulaessige Eingabe --> 50 wird gesetzt iRandomTest = 50; } File tmpDir = new File(pathToWorkDir); /* bestehendes Workverzeichnis Abbruch wenn nicht leer, da am Schluss das Workverzeichnis * gelscht wird und entsprechend bestehende Dateien gelscht werden knnen */ if (tmpDir.exists()) { if (tmpDir.isDirectory()) { // Get list of file in the directory. When its length is not zero the folder is not empty. String[] files = tmpDir.list(); if (files.length > 0) { LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_WORKDIRECTORY_EXISTS, pathToWorkDir))); System.out.println( kostsimy.getTextResourceService().getText(ERROR_WORKDIRECTORY_EXISTS, pathToWorkDir)); System.exit(1); } } } // Im Pfad keine Sonderzeichen Programme knnen evtl abstrzen String patternStr = "[^!#\\$%\\(\\)\\+,\\-_\\.=@\\[\\]\\{\\}\\~:\\\\a-zA-Z0-9 ]"; Pattern pattern = Pattern.compile(patternStr); String name = tmpDir.getAbsolutePath(); String[] pathElements = name.split("/"); for (int i = 0; i < pathElements.length; i++) { String element = pathElements[i]; Matcher matcher = pattern.matcher(element); boolean matchFound = matcher.find(); if (matchFound) { LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name))); System.out.println(kostsimy.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name)); System.exit(1); } } // die Anwendung muss mindestens unter Java 6 laufen String javaRuntimeVersion = System.getProperty("java.vm.version"); if (javaRuntimeVersion.compareTo("1.6.0") < 0) { LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_WRONG_JRE))); System.out.println(kostsimy.getTextResourceService().getText(ERROR_WRONG_JRE)); System.exit(1); } // bestehendes Workverzeichnis wieder anlegen if (!tmpDir.exists()) { tmpDir.mkdir(); File origDirTmp = new File(tmpDir.getAbsolutePath() + File.separator + "orig"); File repDirTmp = new File(tmpDir.getAbsolutePath() + File.separator + "rep"); origDirTmp.mkdir(); repDirTmp.mkdir(); } // Im workverzeichnis besteht kein Schreibrecht if (!tmpDir.canWrite()) { LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_WORKDIRECTORY_NOTWRITABLE, tmpDir))); System.out.println(kostsimy.getTextResourceService().getText(ERROR_WORKDIRECTORY_NOTWRITABLE, tmpDir)); System.exit(1); } // Im Pfad keine Sonderzeichen --> Absturzgefahr name = origDir.getAbsolutePath(); pathElements = name.split("/"); for (int i = 0; i < pathElements.length; i++) { String element = pathElements[i]; Matcher matcher = pattern.matcher(element); boolean matchFound = matcher.find(); if (matchFound) { LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name))); System.out.println(kostsimy.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name)); System.exit(1); } } name = repDir.getAbsolutePath(); pathElements = name.split("/"); for (int i = 0; i < pathElements.length; i++) { String element = pathElements[i]; Matcher matcher = pattern.matcher(element); boolean matchFound = matcher.find(); if (matchFound) { LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name))); System.out.println(kostsimy.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name)); System.exit(1); } } LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_IMAGE1)); float count = 0; int countNio = 0; int countIo = 0; float countVal = 0; int countNotVal = 0; float percentage = (float) 0.0; if (!origDir.isDirectory()) { // TODO: Bildervergleich zweier Dateien --> erledigt --> nur Marker if (repDir.isDirectory()) { // Das Replica-ist ein Verzeichnis, aber Original eine Datei LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_NOREPDIR2, repDir.getAbsolutePath()))); System.out.println( kostsimy.getTextResourceService().getText(ERROR_NOREPDIR2, repDir.getAbsolutePath())); System.exit(1); } boolean compFile = compFile(origDir, logFileName, directoryOfLogfile, repDir, tmpDir); float statIo = 0; int statNio = 0; float statUn = 0; if (compFile) { statIo = 100; } else { statNio = 100; } LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_IMAGE2)); LOGGER.logError( kostsimy.getTextResourceService().getText(MESSAGE_XML_STATISTICS, statIo, statNio, statUn)); LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_LOGEND)); // Zeitstempel End java.util.Date nowEnd = new java.util.Date(); java.text.SimpleDateFormat sdfEnd = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); String ausgabeEnd = sdfEnd.format(nowEnd); ausgabeEnd = "<End>" + ausgabeEnd + "</End>"; Util.valEnd(ausgabeEnd, logFile); Util.amp(logFile); // Die Konfiguration hereinkopieren try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setExpandEntityReferences(false); Document docConfig = factory.newDocumentBuilder().parse(configFile); NodeList list = docConfig.getElementsByTagName("configuration"); Element element = (Element) list.item(0); Document docLog = factory.newDocumentBuilder().parse(logFile); Node dup = docLog.importNode(element, true); docLog.getDocumentElement().appendChild(dup); FileWriter writer = new FileWriter(logFile); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ElementToStream(docLog.getDocumentElement(), baos); String stringDoc2 = new String(baos.toByteArray()); writer.write(stringDoc2); writer.close(); // Der Header wird dabei leider verschossen, wieder zurck ndern String newstring = kostsimy.getTextResourceService().getText(MESSAGE_XML_HEADER); String oldstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><KOSTSimyLog>"; Util.oldnewstring(oldstring, newstring, logFile); } catch (Exception e) { LOGGER.logError( "<Error>" + kostsimy.getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage())); System.out.println("Exception: " + e.getMessage()); } if (compFile) { // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde if (tmpDir.exists()) { Util.deleteDir(tmpDir); } // Validierte Datei valide System.exit(0); } else { // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde if (tmpDir.exists()) { Util.deleteDir(tmpDir); } // Fehler in Validierte Datei --> invalide System.exit(2); } } else { // TODO: Bildervergleich zweier Verzeichnisse --> in Arbeit --> nur Marker if (!repDir.isDirectory()) { // Das Replica-ist eine Datei, aber Original ein Ordner LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_IOE, kostsimy.getTextResourceService().getText(ERROR_NOREPDIR3, repDir.getAbsolutePath()))); System.out.println( kostsimy.getTextResourceService().getText(ERROR_NOREPDIR3, repDir.getAbsolutePath())); System.exit(1); } Map<String, File> fileMap = Util.getFileMap(origDir, false); Set<String> fileMapKeys = fileMap.keySet(); boolean other = false; for (Iterator<String> iterator = fileMapKeys.iterator(); iterator.hasNext();) { String entryName = iterator.next(); File newFile = fileMap.get(entryName); if (!newFile.isDirectory()) { origDir = newFile; count = count + 1; if ((origDir.getAbsolutePath().toLowerCase().endsWith(".pdf") || origDir.getAbsolutePath().toLowerCase().endsWith(".pdfa") || origDir.getAbsolutePath().toLowerCase().endsWith(".tif") || origDir.getAbsolutePath().toLowerCase().endsWith(".tiff") || origDir.getAbsolutePath().toLowerCase().endsWith(".jpeg") || origDir.getAbsolutePath().toLowerCase().endsWith(".jpg") || origDir.getAbsolutePath().toLowerCase().endsWith(".jpe") || origDir.getAbsolutePath().toLowerCase().endsWith(".jp2") || origDir.getAbsolutePath().toLowerCase().endsWith(".gif") || origDir.getAbsolutePath().toLowerCase().endsWith(".png") || origDir.getAbsolutePath().toLowerCase().endsWith(".bmp"))) { percentage = 100 / count * countVal; if (percentage < iRandomTest) { // if ( 100 / count * (countVal + 1) <= iRandomTest ) { countVal = countVal + 1; String origWithOutExt = FilenameUtils.removeExtension(origDir.getName()); File repFile = new File( repDir.getAbsolutePath() + File.separator + origWithOutExt + ".pdf"); if (!repFile.exists()) { repFile = new File( repDir.getAbsolutePath() + File.separator + origWithOutExt + ".pdfa"); if (!repFile.exists()) { repFile = new File( repDir.getAbsolutePath() + File.separator + origWithOutExt + ".tif"); if (!repFile.exists()) { repFile = new File(repDir.getAbsolutePath() + File.separator + origWithOutExt + ".tiff"); if (!repFile.exists()) { repFile = new File(repDir.getAbsolutePath() + File.separator + origWithOutExt + ".jpeg"); if (!repFile.exists()) { repFile = new File(repDir.getAbsolutePath() + File.separator + origWithOutExt + ".jpg"); if (!repFile.exists()) { repFile = new File(repDir.getAbsolutePath() + File.separator + origWithOutExt + ".jpe"); if (!repFile.exists()) { repFile = new File(repDir.getAbsolutePath() + File.separator + origWithOutExt + ".jp2"); if (!repFile.exists()) { repFile = new File(repDir.getAbsolutePath() + File.separator + origWithOutExt + ".gif"); if (!repFile.exists()) { repFile = new File(repDir.getAbsolutePath() + File.separator + origWithOutExt + ".png"); if (!repFile.exists()) { repFile = new File(repDir.getAbsolutePath() + File.separator + origWithOutExt + ".bmp"); if (!repFile.exists()) { other = true; LOGGER.logError(kostsimy .getTextResourceService() .getText(MESSAGE_XML_VALERGEBNIS)); LOGGER.logError(kostsimy .getTextResourceService() .getText(MESSAGE_XML_COMPFILE, origDir)); LOGGER.logError(kostsimy .getTextResourceService().getText( MESSAGE_XML_VALERGEBNIS_NOTVALIDATED)); LOGGER.logError( kostsimy.getTextResourceService() .getText(ERROR_NOREP, origDir.getName())); LOGGER.logError(kostsimy .getTextResourceService().getText( MESSAGE_XML_VALERGEBNIS_CLOSE)); } } } } } } } } } } } if (!other) { boolean compFile = compFile(origDir, logFileName, directoryOfLogfile, repFile, tmpDir); if (compFile) { // Vergleich bestanden countIo = countIo + 1; } else { // Vergleich nicht bestanden countNio = countNio + 1; } } } else { countNotVal = countNotVal + 1; LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS)); LOGGER.logError( kostsimy.getTextResourceService().getText(MESSAGE_XML_COMPFILE, origDir)); LOGGER.logError(kostsimy.getTextResourceService() .getText(MESSAGE_XML_VALERGEBNIS_NOTVALIDATED)); LOGGER.logError( kostsimy.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_CLOSE)); } } else { countNotVal = countNotVal + 1; LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS)); LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_COMPFILE, origDir)); LOGGER.logError( kostsimy.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_NOTVALIDATED)); LOGGER.logError( kostsimy.getTextResourceService().getText(ERROR_INCORRECTFILEENDING, origDir)); LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_CLOSE)); } } } if (countNio == 0 && countIo == 0) { // keine Dateien verglichen LOGGER.logError(kostsimy.getTextResourceService().getText(ERROR_INCORRECTFILEENDINGS)); System.out.println(kostsimy.getTextResourceService().getText(ERROR_INCORRECTFILEENDINGS)); } float statIo = 100 / (float) count * (float) countIo; float statNio = 100 / (float) count * (float) countNio; float statUn = 100 - statIo - statNio; LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_IMAGE2)); LOGGER.logError( kostsimy.getTextResourceService().getText(MESSAGE_XML_STATISTICS, statIo, statNio, statUn)); LOGGER.logError(kostsimy.getTextResourceService().getText(MESSAGE_XML_LOGEND)); // Zeitstempel End java.util.Date nowEnd = new java.util.Date(); java.text.SimpleDateFormat sdfEnd = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); String ausgabeEnd = sdfEnd.format(nowEnd); ausgabeEnd = "<End>" + ausgabeEnd + "</End>"; Util.valEnd(ausgabeEnd, logFile); Util.amp(logFile); // Die Konfiguration hereinkopieren try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setExpandEntityReferences(false); Document docConfig = factory.newDocumentBuilder().parse(configFile); NodeList list = docConfig.getElementsByTagName("configuration"); Element element = (Element) list.item(0); Document docLog = factory.newDocumentBuilder().parse(logFile); Node dup = docLog.importNode(element, true); docLog.getDocumentElement().appendChild(dup); FileWriter writer = new FileWriter(logFile); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ElementToStream(docLog.getDocumentElement(), baos); String stringDoc2 = new String(baos.toByteArray()); writer.write(stringDoc2); writer.close(); // Der Header wird dabei leider verschossen, wieder zurck ndern String newstring = kostsimy.getTextResourceService().getText(MESSAGE_XML_HEADER); String oldstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><KOSTSimyLog>"; Util.oldnewstring(oldstring, newstring, logFile); } catch (Exception e) { LOGGER.logError( "<Error>" + kostsimy.getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage())); System.out.println("Exception: " + e.getMessage()); } if (countNio == 0 && countIo == 0) { // keine Dateien verglichen bestehendes Workverzeichnis ggf. lschen if (tmpDir.exists()) { Util.deleteDir(tmpDir); } System.exit(1); } else if (countNio == 0) { // bestehendes Workverzeichnis ggf. lschen if (tmpDir.exists()) { Util.deleteDir(tmpDir); } // alle Validierten Dateien valide System.exit(0); } else { // bestehendes Workverzeichnis ggf. lschen if (tmpDir.exists()) { Util.deleteDir(tmpDir); } // Fehler in Validierten Dateien --> invalide System.exit(2); } if (tmpDir.exists()) { Util.deleteDir(tmpDir); tmpDir.deleteOnExit(); } } }
From source file:de.fhg.iais.asc.sipmaker.impl.DefaultSipMaker.java
private void addPreprocessingScripts(String scriptsFolder, File sipMakerBaseDir, TransformerListBuilder builder) { File preprocessingFolder = new File(getTransformersDir(sipMakerBaseDir), scriptsFolder); if (!preprocessingFolder.exists()) { throw new AscConfigFailureException("Loading preprocessing scripts failed: Folder '" + preprocessingFolder.getAbsolutePath() + "' does not exist!"); }/* w ww. j ava 2 s . c o m*/ Collection<File> preprocessingScripts = FileUtils.listFiles(preprocessingFolder, new String[] { "xsl" }, true); Iterator<File> scriptIter = preprocessingScripts.iterator(); while (scriptIter.hasNext()) { AbstractTransformer preprocessTransformer = new AscTransformXSLResolver(preprocessingFolder) .createTransformer(FilenameUtils.removeExtension(scriptIter.next().getName())); builder.addTransformer(preprocessTransformer); } }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * DOUBLE IMAGE ROW/*from w w w . java 2s . co m*/ * @param att * @param linear * @return */ public LinearLayout getDoubleImageRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.3f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(3, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value_params); LinearLayout.LayoutParams value_one_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46, 0.35f); ImageView img1 = new ImageView(context); String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value1")); img1.setImageResource(context.getResources().getIdentifier(path, null, null)); img1.setPadding(0, 3, 0, 3); container_layout.addView(img1, value_one_params); LinearLayout.LayoutParams value_two_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46, 0.35f); ImageView img2 = new ImageView(context); path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value2")); img2.setImageResource(context.getResources().getIdentifier(path, null, null)); img2.setPadding(0, 3, 0, 3); container_layout.addView(img2, value_two_params); linear.addView(container_layout); return linear; }
From source file:com.opoopress.maven.plugins.plugin.ThemeMojo.java
private void processParameters() throws MojoFailureException { if (name != null) { if (name.startsWith(OP_THEME_ARTIFACT_PREFIX)) { if (artifactId == null) { artifactId = name;/*ww w.ja v a 2 s .c om*/ } name = name.substring(OP_THEME_ARTIFACT_PREFIX_LENGTH); } else { if (artifactId == null) { artifactId = OP_THEME_ARTIFACT_PREFIX + name; } } } // URL url = null; if (theme != null) { String str = theme.toLowerCase(); //url if (str.startsWith("http://") || str.startsWith("https://")) { try { url = new URL(theme); } catch (MalformedURLException e) { throw new MojoFailureException("Not a valid url: " + theme, e); } if (name == null) { String filename = URIUtil.getName(theme); name = FilenameUtils.removeExtension(filename); } } else { //groupId:artifactId:version[:packaging][:classifier] String[] tokens = StringUtils.split(theme, ":"); if (tokens.length < 3 || tokens.length > 5) { throw new MojoFailureException( "Invalid theme artifact, you must specify groupId:artifactId:version[:packaging][:classifier] " + theme); } groupId = tokens[0]; artifactId = tokens[1]; version = tokens[2]; if (tokens.length >= 4) { type = tokens[3]; } if (tokens.length == 5) { classifier = tokens[4]; } else { classifier = null; } if (name == null) { if (artifactId.startsWith(OP_THEME_ARTIFACT_PREFIX)) { name = artifactId.substring(OP_THEME_ARTIFACT_PREFIX_LENGTH); } else { name = artifactId; } } } } }