openCage-io

version: 0.1.0

Overview

A collection of small java utilities for io especially xplatform paths

  • licence: MPL 1.1
  • platform: java 6
  • lastest version 0.1.0 from TODO
  • Note: interface is not stable yet

Download

Features

FSPath

FSPath describes an absolute path of a file. It abstracts from the underlying platform, no more backward / forward slash confusion. It also defines some standard paths.
e.g.

    FSPath path = FSPathBuilder.getPath( someDir );
    FSPath subPath = path.add( "tmp", "text.txt" );
    FSPath parent = subPath.parent();

    File sub = subPath.toFile();

Standard paths, platform specific for OSX, Windows (Driveletter and UNC), Linux (Debian/Ubuntu):

   FSPathBuilder.getPreferences();
   FSPathBuilder.getDocuments();
   FSPathBuilder.getHome();

Tempfiles and Tempdirectories without creating them, but guarantied to be unique,

   FSPathBuilder.getTmpFile();
   FSPathBuilder.getTmpDir();

Iteration over the path hierarchy

    for ( FSPath subpath : FSPathBuilder.getPath("/a/b/c.txt") ) {
        System.out.println( subpath );   
    }

    "/"
    "/a"
    "/a/b"
    "/a/b/c.txt"

FileUtils

  • Ensure existence of the path to the fspath.
      FileUtils.ensurePath( FSPathBuilder.getPath( "/a/b/c/d.txt") )

Ensures existence of "/a/b/c"

  • CreateFile

Create a file and creates the path if necesarry

  • getJarLocation

Tell me your class and I yell you the location of the jar where it comes from.

With (resource)

Call a lambda on a resource. The Caller, i.e. with, guaranties closing and exception handling.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License