List of usage examples for org.apache.commons.lang3 SystemUtils USER_HOME
String USER_HOME
To view the source code for org.apache.commons.lang3 SystemUtils USER_HOME.
Click Source Link
The user.home System Property.
From source file:eu.ggnet.dwoss.util.TempUtil.java
/** * Tryies to find a location for Temporary files. Optionaly creates the supplied name as Directory an returns a handle. * * @param name the desired name of the directory * @return a handle to a temp directory/* w w w .java2s. com*/ * @throws RuntimeException if somthing goes wrong. */ public static File getDirectory(String name) throws RuntimeException { File outputPath = null; if (SystemUtils.JAVA_IO_TMPDIR != null) outputPath = tryPath(new File(SystemUtils.JAVA_IO_TMPDIR), name); if (outputPath == null) outputPath = tryPath(new File(SystemUtils.USER_HOME), "Temp/" + name); if (outputPath == null) { if (SystemUtils.IS_OS_WINDOWS) { outputPath = tryPath(new File("C:/Temp/"), name); if (outputPath == null) outputPath = tryPath(new File("D:/Temp/"), name); } } if (outputPath == null) throw new RuntimeException("No usable Templocation found, giving up"); return outputPath; }
From source file:de.uniwue.info6.misc.StringTools.java
/** * * * @param path//from www.j av a 2 s.co m * @return */ public static String shortenUnixHomePath(String path) { if (path.startsWith(SystemUtils.USER_HOME) && (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC)) { path = path.replaceFirst(SystemUtils.USER_HOME, "~"); } return path; }
From source file:ch.ivyteam.ivy.maven.BaseEngineProjectMojoTest.java
private static String getLocalRepoPath() { String locaRepoGlobalProperty = System.getProperty("maven.repo.local"); if (locaRepoGlobalProperty != null) { return locaRepoGlobalProperty; }/*from w ww .ja va 2 s . com*/ StringBuilder defaultHomePath = new StringBuilder(SystemUtils.USER_HOME).append(File.separatorChar) .append(".m2").append(File.separatorChar).append("repository"); return defaultHomePath.toString(); }
From source file:com.norconex.commons.wicket.markup.html.filesystem.FileSystemTreeProvider.java
public FileSystemTreeProvider() { this(SystemUtils.USER_HOME); }
From source file:de.uniwue.info6.misc.StringTools.java
/** * * * @param path/*w ww .j a v a 2 s . c om*/ * @return */ public static String shortenUnixHomePathReverse(String path) { if (path.startsWith("~/") && (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC)) { path = path.replace("~/", SystemUtils.USER_HOME + "/"); } return path; }
From source file:com.norconex.commons.wicket.markup.html.filesystem.FileSystemTreeProvider.java
public static boolean isUserHomeRoot(File file) { return file.getPath().equals(SystemUtils.USER_HOME); }
From source file:com.feilong.tools.ant.plugin.jpa.ParseJPATest.java
/** * Test execute target1.//ww w. ja v a 2 s .c o m * * @throws IOException * the IO exception */ @Test public final void getMyTableList() throws IOException { //??log String scanLogFloder = SystemUtils.USER_HOME + "/feilong/dbscan/"; // FileResource fileResource=new FileResource(); // fileResource.setDirectory(directory); // FileScanner fileScanner=new DependScanner(); String inputName = "product"; inputName = "trade"; inputName = "member"; inputName = "platform"; String longTextFile = scanLogFloder + "longtext " + inputName + ".txt"; String ouputfilePath = scanLogFloder + "longtext " + inputName + "-output.txt"; List<Column> longTextColumnlist = aa(longTextFile); //************************************************************************** List<String> list = new ArrayList<String>(); // list.add("mp2-dataCenter"); //list.add("mp2-member"); list.add("mp2-platform"); // list.add("mp2-product"); //list.add("mp2-trade"); for (String projectName : list) { String basedir = "E:/Workspaces/baozun-else/mp2-new/mp2-modules/" + projectName; String[] includes = { "**/repo/*.java" }; String[] excludes = { // "**/package-info.java", // "**/BaseModel.java" }; DirectoryScanner directoryScanner = new DirectoryScanner(); directoryScanner.setBasedir(basedir); directoryScanner.setIncludes(includes); directoryScanner.setExcludes(excludes); directoryScanner.scan(); Map<String, Object> map = DirectoryScannerUtil.getDirectoryScannerMapForLog(directoryScanner); if (log.isDebugEnabled()) { log.debug(JsonUtil.format(map)); } //****************************************************************** ParseJPA parseJPA = new ParseJPA(directoryScanner); String format = JsonUtil.format(parseJPA); if (log.isDebugEnabled()) { log.debug(format); } IOWriteUtil.write(scanLogFloder + projectName + ".txt", format); //****************************************************************** outputLongtextAlter(longTextColumnlist, parseJPA, ouputfilePath); } }
From source file:eu.over9000.skadi.ui.dialogs.PerformUpdateDialog.java
public PerformUpdateDialog(RemoteVersionResult newVersion) { this.chosen = new SimpleObjectProperty<>( Paths.get(SystemUtils.USER_HOME, newVersion.getVersion() + ".jar").toFile()); this.setHeaderText("Updating to " + newVersion.getVersion()); this.setTitle("Skadi Updater"); this.getDialogPane().getStyleClass().add("alert"); this.getDialogPane().getStyleClass().add("information"); final ButtonType restartButtonType = new ButtonType("Start New Version", ButtonBar.ButtonData.OK_DONE); this.getDialogPane().getButtonTypes().addAll(restartButtonType, ButtonType.CANCEL); Node btn = this.getDialogPane().lookupButton(restartButtonType); btn.setDisable(true);/*from w w w . jav a2 s .c om*/ Label lbPath = new Label("Save as"); TextField tfPath = new TextField(); tfPath.textProperty() .bind(Bindings.createStringBinding(() -> this.chosen.get().getAbsolutePath(), this.chosen)); tfPath.setPrefColumnCount(40); tfPath.setEditable(false); Button btChangePath = GlyphsDude.createIconButton(FontAwesomeIcons.FOLDER_OPEN, "Browse..."); btChangePath.setOnAction(event -> { FileChooser fc = new FileChooser(); fc.setTitle("Save downloaded jar.."); fc.setInitialFileName(this.chosen.getValue().getName()); fc.getExtensionFilters().add(new FileChooser.ExtensionFilter("Jar File", ".jar")); fc.setInitialDirectory(this.chosen.getValue().getParentFile()); File selected = fc.showSaveDialog(this.getOwner()); if (selected != null) { this.chosen.set(selected); } }); ProgressBar pbDownload = new ProgressBar(0); pbDownload.setDisable(true); pbDownload.setMaxWidth(Double.MAX_VALUE); Label lbDownload = new Label("Download"); Label lbDownloadValue = new Label(); Button btDownload = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD, "Start"); btDownload.setMaxWidth(Double.MAX_VALUE); btDownload.setOnAction(event -> { btChangePath.setDisable(true); btDownload.setDisable(true); this.downloadService = new DownloadService(newVersion.getDownloadURL(), this.chosen.getValue()); lbDownloadValue.textProperty().bind(this.downloadService.messageProperty()); pbDownload.progressProperty().bind(this.downloadService.progressProperty()); this.downloadService.setOnSucceeded(dlEvent -> { btn.setDisable(false); }); this.downloadService.setOnFailed(dlFailed -> { LOGGER.error("new version download failed", dlFailed.getSource().getException()); lbDownloadValue.textProperty().unbind(); lbDownloadValue.setText("Download failed, check log file for details."); }); this.downloadService.start(); }); final GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.add(lbPath, 0, 0); grid.add(tfPath, 1, 0); grid.add(btChangePath, 2, 0); grid.add(new Separator(), 0, 1, 3, 1); grid.add(lbDownload, 0, 2); grid.add(pbDownload, 1, 2); grid.add(btDownload, 2, 2); grid.add(lbDownloadValue, 1, 3); this.getDialogPane().setContent(grid); this.setResultConverter(btnType -> { if (btnType == restartButtonType) { return this.chosen.getValue(); } if (btnType == ButtonType.CANCEL) { if (this.downloadService.isRunning()) { this.downloadService.cancel(); } } return null; }); }
From source file:com.feilong.taglib.display.sitemap.SiteMapURLTest.java
/** * Test./*from w w w . j a v a2 s . c o m*/ * * @throws IllegalArgumentException * the illegal argument exception * @throws IOException * the IO exception */ @Test public void test() throws IllegalArgumentException, IOException { String templateInClassPath = "velocity/sitemap.vm"; Map<String, Object> contextKeyValues = new HashMap<String, Object>(); List<SiteMapURL> siteMapURLList = new ArrayList<SiteMapURL>(); SiteMapURL siteMapURL = new SiteMapURL(); siteMapURL.setChangefreq(ChangeFreq.daily); siteMapURL.setLastmod(new Date()); siteMapURL.setLoc( "http://www.example.com/?>>> >>>>>>>>>>>><<<<<<<<<<<<<<<<<&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'''''''''''''''''''''"); siteMapURL.setPriority(0.5f); siteMapURLList.add(siteMapURL); siteMapURL = new SiteMapURL(); siteMapURL.setChangefreq(ChangeFreq.monthly); //siteMapURL.setLastmod("2005-01-01"); siteMapURL.setLoc("http://www.example.com/2"); siteMapURL.setPriority(0.5f); siteMapURLList.add(siteMapURL); siteMapURL = new SiteMapURL(); //siteMapURL.setChangefreq(ChangeFreq.monthly); //siteMapURL.setLastmod("2005-01-01"); siteMapURL.setLoc("http://www.example.com/1"); siteMapURL.setPriority(0.5f); siteMapURLList.add(siteMapURL); siteMapURL = new SiteMapURL(); //siteMapURL.setChangefreq(ChangeFreq.monthly); //siteMapURL.setLastmod("2005-01-01"); siteMapURL.setLoc("http://www.example.com/1"); siteMapURL.setPriority(0.5f); siteMapURLList.add(siteMapURL); //siteMapURL = new SiteMapURL(); //siteMapURL.setLoc("http://www.example.com/1"); //siteMapURLList.add(siteMapURL); siteMapURLList.add(null); contextKeyValues.put("siteMapURLList", siteMapURLList); String aString = VelocityUtil.parseTemplateWithClasspathResourceLoader(templateInClassPath, contextKeyValues); //xstre String filePath = SystemUtils.USER_HOME + "/feilong/sitemap.xml"; if (log.isInfoEnabled()) { log.info(aString); } // Document document = Dom4jUtil.getDocument(filePath); // // //document. IOWriteUtil.write(filePath, aString); }
From source file:com.feilong.framework.netpay.payment.BasePaymentTest.java
/** * file path.//from w w w .jav a2 s . c o m * * @return the file path */ private String getFilePath() { Field declaredField = FieldUtil.getDeclaredField(this.getClass(), "paymentAdaptor"); Qualifier qualifier = declaredField.getAnnotation(Qualifier.class); String paymentAdaptorName = qualifier.value(); String fileName = paymentAdaptorName + DateUtil.date2String(new Date(), DatePattern.TIMESTAMP); String folderPath = SystemUtils.USER_HOME + "\\feilong\\payment\\" + paymentAdaptorName; String filePath = folderPath + "\\" + fileName + ".html"; return filePath; }