read URL File - Java Network

Java examples for Network:URL

Description

read URL File

Demo Code


//package com.java2s;

import java.net.URL;

public class Main {
    public static void main(String[] argv) throws Exception {
        Class classType = String.class;
        String fileName = "java2s.com";
        System.out.println(getURLFile(classType, fileName));
    }/*from w ww .  jav  a 2s .  c o m*/

    public static URL getURLFile(Class<?> classType, String fileName) {
        URL fileURL = classType.getClassLoader().getResource(fileName);
        return fileURL;
    }
}

Related Tutorials