List of usage examples for java.nio.file Paths get
public static Path get(URI uri)
From source file:com.github.ffremont.microservices.springboot.node.tasks.AbstractInstallTest.java
public void before() throws IOException { this.remove(Paths.get(nodeBase)); }
From source file:org.gkh.racf.JSONUtil.java
public static JSONObject getJSONFromFile(String path) throws IOException, JSONException { // (1) Read JSON file into a string and attempt to parse it. byte[] encoded = Files.readAllBytes(Paths.get(path)); String json = new String(encoded, "UTF-8"); if (isValidJSON(json)) { return new JSONObject(json); }/*from w w w . j a v a2 s. c o m*/ return null; }
From source file:dk.dma.msinm.common.mail.AttachmentMailPart.java
/** * Instantiates an attachment mail part from a file * @param file the attachment file//from w ww.j a va 2s . c o m * @param name the name of the attachment. */ public static AttachmentMailPart fromFile(String file, String name) throws MessagingException { // Check that the file is valid Path path = Paths.get(file); if (!Files.isRegularFile(path)) { throw new MessagingException("Invalid file attachment: " + file); } // If name is not specified, compute it from the file if (StringUtils.isBlank(name)) { name = path.getFileName().toString(); } // Instantiate a mail attachment AttachmentMailPart a = new AttachmentMailPart(name); a.file = file; return a; }
From source file:org.cloudfoundry.dependency.in.InConfiguration.java
@Bean Path destination(ApplicationArguments applicationArguments) { Path destination = Paths.get(applicationArguments.getSourceArgs()[0]); this.logger.debug("Destination: {}", destination); return destination; }
From source file:at.makubi.maven.plugin.avrohugger.AvrohuggerGeneratorTest.java
@Before public void setUp() throws Exception { avrohuggerGenerator = new AvrohuggerGenerator(); outputDirectory = Files.createTempDirectory(Paths.get(getBasedir()).resolve("target"), AvrohuggerGeneratorTest.class.getCanonicalName()); }
From source file:edu.usc.goffish.gofs.tools.deploy.SCPPartitionDistributer.java
public SCPPartitionDistributer() { this(Paths.get(DefaultSCPBinary), null, 1, -1); }
From source file:com.betel.flowers.web.bean.util.UploadFileRun.java
@Override public void run() { Boolean succesefull = Boolean.FALSE; Path path = Paths.get(url); //if directory exists? if (!Files.exists(path)) { try {//from www . jav a2 s . c o m Files.createDirectories(path); log.log(Level.INFO, "Directory is created!"); } catch (IOException e) { //fail to create directory log.log(Level.SEVERE, "Failed to create directory! " + e.getMessage()); } } File fileDelete = new File(url + name + "." + ext); if (fileDelete.delete()) { log.log(Level.INFO, "Se elimino el archivo: " + url + name + "." + ext); } else { log.log(Level.INFO, "No se elimino el archivo: " + url + name + "." + ext); } File file = new File(url + name + "." + ext); try { byte[] imgbytes = IOUtils.toByteArray(input); InputStream in = new ByteArrayInputStream(imgbytes); BufferedImage bImageFromConvert = ImageIO.read(in); ImageIO.write(bImageFromConvert, ext, file); succesefull = Boolean.TRUE; } catch (IOException e) { log.log(Level.SEVERE, "Error al guardar la imagen en:" + file.getPath(), e); } if (succesefull) { try { this.finalize(); this.exito = true; } catch (Throwable ex) { log.log(Level.SEVERE, "Error al procesar imagen", ex); } } else { this.interrupt(); this.exito = false; } }
From source file:edu.jhu.hlt.concrete.gigaword.IngesterTest.java
/** * @throws java.lang.Exception//from ww w .j a v a 2 s. co m */ @Before public void setUp() throws Exception { p = Paths.get("src/test/resources/serif_dog-bites-man.sgml"); if (!Files.exists(p)) fail("Need to have: " + p.toString() + " to run this test."); }
From source file:com.derpgroup.skillscraper.SkillsFileUtils.java
public static void writeSkill(String outputPath, Skill skill, List<SkillReview> skillReviews) { String skillOutputPath = String.format(outputPath + "%s/", skill.getAsin()); Path skillPath = Paths.get(skillOutputPath); try {/* w w w . j a v a 2 s . c o m*/ Files.createDirectories(skillPath); } catch (IOException e1) { e1.printStackTrace(); } try { mapper.writeValue(new File(skillOutputPath + skill.getName() + ".json"), skill); } catch (JsonGenerationException e) { e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (skillReviews != null && skillReviews.size() > 0) { writeSkillReviews(skillOutputPath, skillReviews); } }
From source file:cane.brothers.e4.commander.utils.PathUtils.java
/** * Default path can be different for various OS * /*from w w w .j av a2s . co m*/ * @return default path */ public static Path getDefaultPath() { Path defaultPath = Paths.get(""); //$NON-NLS-1$ if (SystemUtils.IS_OS_WINDOWS) { defaultPath = Paths.get("C:\\"); //$NON-NLS-1$ } else if (SystemUtils.IS_OS_MAC_OSX) { defaultPath = Paths.get(System.getenv().get("HOME")); //$NON-NLS-1$ } return defaultPath; }