Java URL to File Name getFileFor(URL url1)

Here you can find the source of getFileFor(URL url1)

Description

get File For

License

Open Source License

Declaration

private static File getFileFor(URL url1) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2005, 2009 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://ww  w . j  av a2 s.  c o  m
 *     IBM Corporation - initial API and implementation
 *     Chris Aniszczyk (IBM Corp.) - Fixed NPE
 *******************************************************************************/

import java.io.*;

import java.net.URL;
import java.util.*;

public class Main {
    private static Map urlFileMap;

    private static File getFileFor(URL url1) {
        if (urlFileMap == null)
            urlFileMap = new HashMap();
        if (urlFileMap.get(url1) != null)
            return (File) urlFileMap.get(url1);
        File newFile = new File(url1.getFile());
        urlFileMap.put(url1, newFile);
        return newFile;
    }
}

Related

  1. getFile(URL url)
  2. getFile(URL url, String description)
  3. getFileAbsoluteURL(String[] directoryPaths, String fileName)
  4. getFileDateTime(URL url)
  5. getFileExtensionByURL(URL url)
  6. getFileForURL(String url)
  7. getFileForUrl(URL url)
  8. getFileFrom(final URL url)
  9. getFileFromUrl(String url, File base)