public WFile readFile(String strPath) { File objFile = new File(strPath); HashMap hmConts = new HashMap(); setHM(strPath, hmConts); return new WFile(objFile.lastModified(), hmConts); }
/*.................................................................................................................*/ public void processOutputFiles() { if (outputFileProcessor != null && outputFilePaths != null && lastModified != null) { String[] paths = outputFileProcessor.modifyOutputPaths(outputFilePaths); for (int i = 0; i < paths.length && i < lastModified.length; i++) { File file = new File(paths[i]); long lastMod = file.lastModified(); if (!MesquiteLong.isCombinable(lastModified[i]) || lastMod > lastModified[i]) { outputFileProcessor.processOutputFile(paths, i); lastModified[i] = lastMod; } } } }
// ===================================================== // setEXIFpictureMetadaten() // // Aus dem Image-Original werden die EXIF-Daten f�r die // PM_PictureMetadatenX geholt und eingetragen // ===================================================== public static void setEXIFpictureMetadaten(PM_Picture picture) { PM_PictureImageMetadaten imageMetadaten = picture.getImageMetadaten(); // ---------------------------------------------------- // FujiFilm Makernote: SequenceNummer --> virtPicture // ---------------------------------------------------- // ------------------------------------------------------- // Date // ------------------------------------------------------ String tagDatum = "Date/Time Original"; String description = ""; if (imageMetadaten.hasTag(tagDatum)) { description = imageMetadaten.getDescription(tagDatum); } // ---------------------------------------------------- // Datum nicht vorhanden oder ung�ltig // ---------------------------------------------------- Date myDate = null; if (description.length() == 0 || description.equals("0000:00:00 00:00:00")) { // System.out.println("...... Datum = " + description + " kann nicht konvertiert // werden"); File f = picture.getFileOriginal(); Date date = new Date(f.lastModified()); picture.meta.setDateImport(date); picture.meta.setDateCurrent(new Date(date.getTime())); return; } // ---------------------------------------------------- // g�ltiges Datum gefunden // ---------------------------------------------------- DateFormat df = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss"); try { myDate = df.parse(description); } catch (ParseException e) { // System.out.println("ParseException fuer Datum = " + description); myDate = new Date(System.currentTimeMillis()); // default } picture.meta.setDateImport(myDate); picture.meta.setDateCurrent(new Date(myDate.getTime())); }
@Nullable private static File findOldConfigDir( @NotNull File configDir, @Nullable String customPathSelector) { final File selectorDir = CONFIG_RELATED_PATH.isEmpty() ? configDir : configDir.getParentFile(); final File parent = selectorDir.getParentFile(); if (parent == null || !parent.exists()) { return null; } File maxFile = null; long lastModified = 0; final String selector = PathManager.getPathsSelector() != null ? PathManager.getPathsSelector() : selectorDir.getName(); final String prefix = getPrefixFromSelector(selector); final String customPrefix = customPathSelector != null ? getPrefixFromSelector(customPathSelector) : null; for (File file : parent.listFiles( new FilenameFilter() { @Override public boolean accept(@NotNull File file, @NotNull String name) { return StringUtil.startsWithIgnoreCase(name, prefix) || customPrefix != null && StringUtil.startsWithIgnoreCase(name, customPrefix); } })) { File options = new File(file, CONFIG_RELATED_PATH + OPTIONS_XML); if (!options.exists()) { continue; } long modified = options.lastModified(); if (modified > lastModified) { lastModified = modified; maxFile = file; } } return maxFile != null ? new File(maxFile, CONFIG_RELATED_PATH) : null; }
public static void main(String[] arg) { if (arg.length != 2) { System.err.println("usage: java ScpTo file1 user@remotehost:file2"); System.exit(-1); } FileInputStream fis = null; try { String lfile = arg[0]; String user = arg[1].substring(0, arg[1].indexOf('@')); arg[1] = arg[1].substring(arg[1].indexOf('@') + 1); String host = arg[1].substring(0, arg[1].indexOf(':')); String rfile = arg[1].substring(arg[1].indexOf(':') + 1); JSch jsch = new JSch(); Session session = jsch.getSession(user, host, 22); // username and password will be given via UserInfo interface. UserInfo ui = new MyUserInfo(); session.setUserInfo(ui); session.connect(); boolean ptimestamp = true; // exec 'scp -t rfile' remotely String command = "scp " + (ptimestamp ? "-p" : "") + " -t " + rfile; Channel channel = session.openChannel("exec"); ((ChannelExec) channel).setCommand(command); // get I/O streams for remote scp OutputStream out = channel.getOutputStream(); InputStream in = channel.getInputStream(); channel.connect(); if (checkAck(in) != 0) { System.exit(0); } File _lfile = new File(lfile); if (ptimestamp) { command = "T " + (_lfile.lastModified() / 1000) + " 0"; // The access time should be sent here, // but it is not accessible with JavaAPI ;-< command += (" " + (_lfile.lastModified() / 1000) + " 0\n"); out.write(command.getBytes()); out.flush(); if (checkAck(in) != 0) { System.exit(0); } } // send "C0644 filesize filename", where filename should not include '/' long filesize = _lfile.length(); command = "C0644 " + filesize + " "; if (lfile.lastIndexOf('/') > 0) { command += lfile.substring(lfile.lastIndexOf('/') + 1); } else { command += lfile; } command += "\n"; out.write(command.getBytes()); out.flush(); if (checkAck(in) != 0) { System.exit(0); } // send a content of lfile fis = new FileInputStream(lfile); byte[] buf = new byte[1024]; while (true) { int len = fis.read(buf, 0, buf.length); if (len <= 0) break; out.write(buf, 0, len); // out.flush(); } fis.close(); fis = null; // send '\0' buf[0] = 0; out.write(buf, 0, 1); out.flush(); if (checkAck(in) != 0) { System.exit(0); } out.close(); channel.disconnect(); session.disconnect(); System.exit(0); } catch (Exception e) { System.out.println(e); try { if (fis != null) fis.close(); } catch (Exception ee) { } } }