Example usage for java.net URL getPath

List of usage examples for java.net URL getPath

Introduction

In this page you can find the example usage for java.net URL getPath.

Prototype

public String getPath() 

Source Link

Document

Gets the path part of this URL .

Usage

From source file:Main.java

public static void main(String args[]) throws Exception {
    URL u = new URL("http://www.yourserver.com:80/abc/demo.htm");
    System.out.println("The URL is " + u);
    System.out.println("The path part is " + u.getPath());

}

From source file:fr.inria.maestro.lga.examples.SSLMExample2.java

public static void main(String[] args) throws IOException {
    //load graph/* ww  w.j av a  2  s  .  c o  m*/
    int numberOfSeeds = 1;
    double alpha = 0.85;
    double sigma = 0.0;
    String shortLink = "/graph/bvg/";
    URL url = SSLMExample2.class.getResource(shortLink);
    String dir = url.getPath();
    String name = "LesMisrablesWeighted";
    String namer = "LesMisrablesNames.txt";
    String expertName = "LesMiserablesExpert.txt";
    final File expertFile = FileUtils.toFile(SSLMExample.class.getResource(shortLink + expertName));

    IClustering expert = Data.loadClustering(expertFile);
    IGraph graph = Data.loadGraphBVG(dir, name, namer);
    System.out.println("nodes=" + graph.numNodes() + " edges=" + graph.numArcs());
    System.out.println("WeightedGraph:" + (graph instanceof IArcWeightedGraph));
    IClustering seeds = SeedChooser.getMaxPRSeeds(graph, numberOfSeeds, expert);

    System.out.println("\n***Estimations for weighted graph:");
    IClustering algoCl = doClassificationWeightedGraph(graph, seeds, sigma, alpha);
    SSLMExample.doEsteem(graph, expert, algoCl);

    System.out.println("\n***Estimations for unweighted graph:");
    IClustering algoCl2 = SSLMExample.doClassification(graph, seeds, sigma, alpha);
    SSLMExample.doEsteem(graph, expert, algoCl2);
}

From source file:common.ConfigTest.java

public static void main(String[] args) {
    URL configURL = ConfigTest.class.getResource("config.xml");
    DefaultConfigurationBuilder db = new DefaultConfigurationBuilder();
    db.setConfigurationBasePath(configURL.getPath());
    Configuration configuration = null;
    try {//from www. j a v a  2 s. c  om
        configuration = db.getConfiguration();
    } catch (ConfigurationException ex) {

    }

    if (configuration != null) {
        String[] fileNames = configuration.getStringArray("fileName");
        for (String fileName : fileNames) {
            System.out.println(fileName);
        }
    }

}

From source file:Main.java

public static void main(String[] args) throws IOException {
    URL[] urls = { new URL("http://yourserver/small.png") };
    for (URL url : urls) {
        ImageInputStream iis = ImageIO.createImageInputStream(url.openStream());
        Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);

        System.out.println("url= " + url.getPath());
        while (readers.hasNext()) {
            ImageReader read = readers.next();
            System.out.println("format name = " + read.getFormatName());
        }//from  w  ww.jav a 2s .c  o  m
        System.out.println();
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    try {//from   w  w  w . j av  a  2s .  c o m
        URL url = new URL("http://www.java2s.com");
        System.out.println("URL is " + url.toString());
        System.out.println("authority is " + url.getAuthority());
        System.out.println("path is " + url.getPath());
        System.out.println("default port is " + url.getDefaultPort());
        System.out.println("query is " + url.getQuery());
        System.out.println("ref is " + url.getRef());
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.yahoo.com:80/en/index.html?name=joe#first");
    System.out.println("protocol:" + url.getProtocol());
    System.out.println("prot:" + url.getPort());
    System.out.println("host:" + url.getHost());
    System.out.println("path:" + url.getPath());
    System.out.println("file:" + url.getFile());
    System.out.println("query:" + url.getQuery());
    System.out.println("ref:" + url.getRef());
}

From source file:com.tonygalati.sprites.SpriteGenerator.java

public static void main(String[] args) throws IOException {

    //        if (args.length != 3)
    //        {//from w  w  w  . java  2s.c  o  m
    //           System.out.print("Usage: com.tonygalati.sprites.SpriteGenerator {path to images} {margin between images in px} {output file}\n");
    //           System.out.print("Note: The max height should only be around 32,767px due to Microsoft GDI using a 16bit signed integer to store dimensions\n");
    //           System.out.print("going beyond this dimension is possible with this tool but the generated sprite image will not work correctly with\n");
    //           System.out.print("most browsers.\n\n");
    //           return;
    //        }

    //        Integer margin = Integer.parseInt(args[1]);
    Integer margin = Integer.parseInt("1");
    String spriteFile = "icons-" + RandomStringUtils.randomAlphanumeric(10) + ".png";
    SpriteCSSGenerator cssGenerator = new SpriteCSSGenerator();

    ClassLoader classLoader = SpriteGenerator.class.getClassLoader();
    URL folderPath = classLoader.getResource(NAIC_SMALL_ICON);
    if (folderPath != null) {
        File imageFolder = new File(folderPath.getPath());

        // Read images
        ArrayList<BufferedImage> imageList = new ArrayList<BufferedImage>();
        Integer yCoordinate = null;

        for (File f : imageFolder.listFiles()) {
            if (f.isFile()) {
                String fileName = f.getName();
                String ext = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());

                if (ext.equals("png")) {
                    System.out.println("adding file " + fileName);
                    BufferedImage image = ImageIO.read(f);
                    imageList.add(image);

                    if (yCoordinate == null) {
                        yCoordinate = 0;
                    } else {
                        yCoordinate += (image.getHeight() + margin);
                    }

                    // add to cssGenerator
                    cssGenerator.addSpriteCSS(fileName.substring(0, fileName.indexOf(".")), 0, yCoordinate);
                }
            }
        }

        // Find max width and total height
        int maxWidth = 0;
        int totalHeight = 0;

        for (BufferedImage image : imageList) {
            totalHeight += image.getHeight() + margin;

            if (image.getWidth() > maxWidth)
                maxWidth = image.getWidth();
        }

        System.out.format("Number of images: %s, total height: %spx, width: %spx%n", imageList.size(),
                totalHeight, maxWidth);

        // Create the actual sprite
        BufferedImage sprite = new BufferedImage(maxWidth, totalHeight, BufferedImage.TYPE_INT_ARGB);

        int currentY = 0;
        Graphics g = sprite.getGraphics();
        for (BufferedImage image : imageList) {
            g.drawImage(image, 0, currentY, null);
            currentY += image.getHeight() + margin;
        }

        System.out.format("Writing sprite: %s%n", spriteFile);
        ImageIO.write(sprite, "png", new File(spriteFile));
        File cssFile = cssGenerator.getFile(spriteFile);
        System.out.println(cssFile.getAbsolutePath() + " created");
    } else {
        System.err.println("Could not find folder: " + NAIC_SMALL_ICON);

    }

}

From source file:com.nieyue.weixin.ssl.ClientCustomSSL.java

public final static void main(String[] args) throws Exception {
    //File file = new File(System.getProperty("user.dir")+"/src/com/nieyue/weixin/ssl/apiclient_cert.p12");
    //URL path = ClientCustomSSL.class.getClassLoader().getResource("/src/com/nieyue/weixin/ssl/apiclient_cert.p12");
    URL path = ClientCustomSSL.class.getResource("");
    new MyFile().imageRW("WebRoot/resources/img/404.jpg", "WebRoot/resources/payQRCode/test.jpg", "png");
    //File file = new File(path.getPath());
    System.out.println(path.getPath() + "sdfsd");
    //System.out.println(file.getAbsolutePath());
    //System.out.println(file.getCanonicalPath());
    //System.out.println(file.getPath());
    System.out.println(getCloseableHttpClient());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    URL url = new URL(args[0]);
    System.out.println("URL is " + url.toString());
    System.out.println("protocol is " + url.getProtocol());
    System.out.println("authority is " + url.getAuthority());
    System.out.println("file name is " + url.getFile());
    System.out.println("host is " + url.getHost());
    System.out.println("path is " + url.getPath());
    System.out.println("port is " + url.getPort());
    System.out.println("default port is " + url.getDefaultPort());
    System.out.println("query is " + url.getQuery());
    System.out.println("ref is " + url.getRef());
}

From source file:de.jwi.ftp.FTPUploader.java

public static void main(String[] args) throws Exception {
    URL url = new URL("ftp://ftp:none@localhost/tmp");
    String protocol = url.getProtocol();

    String host = url.getHost();//www.j  a  v  a  2s.  c o m
    String userInfo = url.getUserInfo();
    String path = url.getPath();
    String file = url.getFile();

    File f = new File("D:/temp/out");
    List l = new ArrayList();
    l.add(f);
    String s = upload(url, l);
    System.out.println(s);
    int x = 5;
}