java类java.io.File的实例源码

SmallObjectHeap.java 文件源码 项目:dxram 阅读 22 收藏 0 点赞 0 评论 0
public SmallObjectHeap(final String p_memDumpFile, final Storage p_memory) {
    m_memory = p_memory;

    File file = new File(p_memDumpFile);

    if (!file.exists()) {
        throw new MemoryRuntimeException("Cannot create heap from mem dump " + p_memDumpFile + ": file does not exist");
    }

    RandomAccessFileImExporter importer;
    try {
        importer = new RandomAccessFileImExporter(file);
    } catch (final FileNotFoundException e) {
        // cannot happen
        throw new MemoryRuntimeException("Illegal state", e);
    }

    importer.importObject(this);
}
DiskChecker.java 文件源码 项目:hadoop-oss 阅读 25 收藏 0 点赞 0 评论 0
/** 
 * The semantics of mkdirsWithExistsCheck method is different from the mkdirs
 * method provided in the Sun's java.io.File class in the following way:
 * While creating the non-existent parent directories, this method checks for
 * the existence of those directories if the mkdir fails at any point (since
 * that directory might have just been created by some other process).
 * If both mkdir() and the exists() check fails for any seemingly 
 * non-existent directory, then we signal an error; Sun's mkdir would signal
 * an error (return false) if a directory it is attempting to create already
 * exists or the mkdir fails.
 * @param dir
 * @return true on success, false on failure
 */
public static boolean mkdirsWithExistsCheck(File dir) {
  if (dir.mkdir() || dir.exists()) {
    return true;
  }
  File canonDir = null;
  try {
    canonDir = dir.getCanonicalFile();
  } catch (IOException e) {
    return false;
  }
  String parent = canonDir.getParent();
  return (parent != null) && 
         (mkdirsWithExistsCheck(new File(parent)) &&
                                    (canonDir.mkdir() || canonDir.exists()));
}
AidlProcessor.java 文件源码 项目:Jar2Java 阅读 30 收藏 0 点赞 0 评论 0
private void processSubFiles(File file, ProcessSubAIDLFileCallback callback) {
    if (file == null) {
        return;
    }
    if (file.isDirectory()) {
        File[] files = file.listFiles();
        if (files != null && files.length > 0) {
            for (File f : files) {
                processSubFiles(f, callback);
            }
        }
    } else {
        if (callback.matchFile(file)) {
            callback.processFile(file);
        }
    }
}
TestHostConfigAutomaticDeployment.java 文件源码 项目:tomcat7 阅读 31 收藏 0 点赞 0 评论 0
private void doTestUnpackWAR(boolean unpackWARs, boolean unpackWAR,
        boolean external, boolean resultDir) throws Exception {

    Tomcat tomcat = getTomcatInstance();
    StandardHost host = (StandardHost) tomcat.getHost();

    host.setUnpackWARs(unpackWARs);

    tomcat.start();

    File war;
    if (unpackWAR) {
        war = createWar(WAR_XML_UNPACKWAR_TRUE_SOURCE, !external);
    } else {
        war = createWar(WAR_XML_UNPACKWAR_FALSE_SOURCE, !external);
    }
    if (external) {
        createXmlInConfigBaseForExternal(war);
    }

    host.backgroundProcess();

    File dir = new File(host.getAppBase(), APP_NAME.getBaseName());
    Assert.assertEquals(
            Boolean.valueOf(resultDir), Boolean.valueOf(dir.isDirectory()));
}
OfflineFile.java 文件源码 项目:AndroidSDK2.0 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Sets offline file path.
 *
 * @param newPath the new path
 * @return the offline file path
 */
public synchronized static boolean setOfflineFilePath( String newPath )
{
    if ( !newPath.endsWith( "/" ) )
    {
        newPath = newPath + "/";
    }

    File newTarget = new File( newPath );

    if ( !newTarget.exists() || !newTarget.isDirectory() )
    {
        return false;
    }

    OFFLINE_FILE_PATH = newPath;

    return true;
}
CreateBundle.java 文件源码 项目:incubator-netbeans 阅读 26 收藏 0 点赞 0 评论 0
private Properties readProperties(Vector <? extends Property> antProperties) throws IOException {
    Properties props = new Properties();
    for(Property prop : antProperties) {
        if(prop.getName()!=null) {
            if(prop.getValue()!=null) {
                props.setProperty(prop.getName(), prop.getValue());
            } else if(prop.getLocation()!=null) {
                props.setProperty(prop.getName(),
                        new File(prop.getLocation().getFileName()).getAbsolutePath());
            }
        } else if(prop.getFile()!=null || prop.getUrl()!=null) {
            InputStream is = null;
            try {
                is = (prop.getFile()!=null) ?
                    new FileInputStream(prop.getFile()) :
                    prop.getUrl().openStream();

                Properties loadedProps = new Properties();
                loadedProps.load(is);
                is.close();
                if ( prop.getPrefix() != null ) {
                    for(Object p : loadedProps.keySet()) {
                        props.setProperty(prop.getPrefix() + p,
                                loadedProps.getProperty(p.toString()));
                    }
                } else {
                    props.putAll(loadedProps);
                }
            } finally {
                if (is != null) {
                    is.close();
                }
            }
        }
    }

    return props;
}
CheckoutTest.java 文件源码 项目:incubator-netbeans 阅读 25 收藏 0 点赞 0 评论 0
public void testCheckoutFilesFromIndexFileToFolder () throws Exception {
    File folder = new File(workDir, "folder");
    File subFolder = new File(folder, "folder");
    File file1 = new File(subFolder, "file2");
    subFolder.mkdirs();
    write(file1, "file 1 content");
    File[] files = new File[] { folder };
    add(files);
    commit(files);

    file1.delete();
    subFolder.delete();
    folder.delete();
    write(folder, "blabla");

    GitClient client = getClient(workDir);
    Map<File, GitStatus> statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
    assertStatus(statuses, workDir, file1, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_REMOVED, GitStatus.Status.STATUS_REMOVED, false);
    client.checkout(new File[] { folder }, null, true, NULL_PROGRESS_MONITOR);
    statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
    assertStatus(statuses, workDir, file1, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
    assert(file1.isFile());
    assertEquals("file 1 content", read(file1));
}
UpdateService.java 文件源码 项目:Ency 阅读 28 收藏 0 点赞 0 评论 0
private void startDownload() {
    File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "ency.apk");
    AppFileUtil.delFile(file, true);
    // 创建下载任务
    DownloadManager.Request request = new DownloadManager.Request(Uri.parse("http://ucdl.25pp.com/fs08/2017/09/19/10/2_b51f7cae8d7abbd3aaf323a431826420.apk?sf=9946816&vh=1e3a8680ee88002bdf2f00f715146e16&sh=10&cc=3646561943&appid=7060083&packageid=400525966&md5=27456638a0e6615fb5153a7a96c901bf&apprd=7060083&pkg=com.taptap&vcode=311&fname=TapTap&pos=detail-ndownload-com.taptap"));
    // 显示下载信息
    request.setTitle("Ency");
    request.setDescription("新版本下载中");
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
    request.setMimeType("application/vnd.android.package-archive");
    // 设置下载路径
    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "ency.apk");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        request.allowScanningByMediaScanner();
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    }
    // 获取DownloadManager
    dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    // 将下载请求加入下载队列,加入下载队列后会给该任务返回一个long型的id,通过该id可以取消任务,重启任务、获取下载的文件等等
    downloadId = dm.enqueue(request);
    Toast.makeText(this, "后台下载中,请稍候...", Toast.LENGTH_SHORT).show();
}
MainExample3.java 文件源码 项目:fluxtion-examples 阅读 31 收藏 0 点赞 0 评论 0
private static void replayAuditLog() {
    System.out.println("\n\nStarting replay with new instance of G10Monitor");
    System.out.println("=================================================================================================");
    G10Monitor monitor = new G10Monitor();
    monitor.registerBreachNotificationHandler(new ConsoleBreachHandler());
    monitor.registerResultsReceiver(new OrderBiasResultPrinter());
    monitor.registerEventAuditor(new ConsoleAuditor());
    CsvAuditReplay replay = new CsvAuditReplay();
    /**
     * Disable all audit and publishing with: 
     * monitor.enableAudit(true);
     * monitor.enableResultPublication(true);
     * monitor.enableResultPublication(true);
     */
    replay.replay(monitor, new File("target\\generated-sources\\testlog\\fluxtionfx-audit.log"));
    System.out.println("=================================================================================================");

}
Utils.java 文件源码 项目:BlackList 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Makes file path if it doesn't exist
 **/
public static boolean makeFilePath(File file) {
    String parent = file.getParent();
    if (parent != null) {
        File dir = new File(parent);
        try {
            if (!dir.exists() && !dir.mkdirs()) {
                throw new SecurityException("File.mkdirs() returns false");
            }
        } catch (SecurityException e) {
            Log.w(TAG, e);
            return false;
        }
    }

    return true;
}
FileCoordinatorRepository.java 文件源码 项目:happylifeplat-tcc 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 更新 List<Participant>  只更新这一个字段数据
 *
 * @param tccTransaction 实体对象
 */
@Override
public int updateParticipant(TccTransaction tccTransaction) {
    try {

        final String fullFileName = RepositoryPathUtils.getFullFileName(filePath,tccTransaction.getTransId());
        final File file = new File(fullFileName);
        final CoordinatorRepositoryAdapter adapter = readAdapter(file);
        if(Objects.nonNull(adapter)){
            adapter.setContents(serializer.serialize(tccTransaction.getParticipants()));
        }
        FileUtils.writeFile(fullFileName,serializer.serialize(adapter));

    } catch (Exception e) {
        throw new TccRuntimeException("更新数据异常!");
    }
    return 1;
}
PathBuilder.java 文件源码 项目:oscm 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Creates a new builder for the given project.
 * 
 * @param eclipseProject
 */
public PathBuilder(Project antProject, IEclipseProject eclipseProject,
        File workdir) {
    this.antProject = antProject;
    this.eclipseProject = eclipseProject;
    this.workdir = workdir;
}
StreamableOutput.java 文件源码 项目:kestrel 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Get a streamable output object.
 * 
 * @param file File.
 * @param fd File descriptor.
 * @param name Name for error, warnings, and documentation.
 */
private StreamableOutput(File file, FileDescriptor fd, String name) {

    // Exactly one of file or fd must be set
    assert (file != null) || (fd != null) :
        "File and file descriptor are both null (exactly one must be null)";

    assert (file == null) || (fd == null) :
        "Neither file nor file descriptor null (exactly one must be null)";

    // Set fields
    this.file = file;
    this.fd = fd;
    this.name = name;

    return;
}
MarkupManipulator.java 文件源码 项目:qpp-conversion-tool 阅读 37 收藏 0 点赞 0 评论 0
public InputStream upsetTheNorm(String xPath, boolean remove) {
    try {
        document = dbf.newDocumentBuilder().parse(new File(pathname));
        XPath xpath = xpf.newXPath();
        XPathExpression expression = xpath.compile(xPath);

        NodeList searchedNodes = (NodeList) expression.evaluate(document, XPathConstants.NODESET);
        if (searchedNodes == null) {
            System.out.println("bad path: " + xPath);
        } else {
            for (int i = 0; i < searchedNodes.getLength(); i++) {
                Node searched = searchedNodes.item(i);

                Node owningElement = (searched instanceof ElementImpl)
                        ? searched
                        : ((AttrImpl) searched).getOwnerElement();

                Node containingParent = owningElement.getParentNode();

                if (remove) {
                    containingParent.removeChild(owningElement);
                } else {
                    containingParent.appendChild(owningElement.cloneNode(true));
                }

            }
        }

        Transformer t = tf.newTransformer();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Result result = new StreamResult(os);
        t.transform(new DOMSource(document), result);
        return new ByteArrayInputStream(os.toByteArray());
    } catch (ParserConfigurationException | IOException | SAXException |
            XPathExpressionException | TransformerException ex) {
        throw new RuntimeException(ex);
    }
}
TestParser.java 文件源码 项目:apache-tomcat-7.0.73-with-comment 阅读 36 收藏 0 点赞 0 评论 0
@Test
public void testBug49297NoSpaceStrict() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

    tomcat.start();

    int sc = getUrl("http://localhost:" + getPort() +
            "/test/bug49nnn/bug49297NoSpace.jsp", new ByteChunk(),
            new HashMap<String,List<String>>());

    assertEquals(500, sc);
}
ImageUtil.java 文件源码 项目:JAVA- 阅读 29 收藏 0 点赞 0 评论 0
/**
 * * 转换图片大小,不变形
 * 
 * @param img 图片文件
 * @param width 图片宽
 * @param height 图片高
 */
public static final void changeImge(File img, int width, int height) {
    try {
        Thumbnails.of(img).size(width, height).keepAspectRatio(false).toFile(img);
    } catch (IOException e) {
        e.printStackTrace();
        throw new IllegalStateException("图片转换出错!", e);
    }
}
SignJarsTask.java 文件源码 项目:incubator-netbeans 阅读 26 收藏 0 点赞 0 评论 0
private static void extendLibrariesManifests(
    final Project prj,
    final File mainJar,
    final List<? extends File> libraries) throws IOException {
    String codebase = null;
    String permissions = null;
    String appName = null;
    final JarFile jf = new JarFile(mainJar);
    try {
        final java.util.jar.Manifest mf = jf.getManifest();
        if (mf != null) {
            final Attributes attrs = mf.getMainAttributes();
            codebase = attrs.getValue(ATTR_CODEBASE);
            permissions = attrs.getValue(ATTR_PERMISSIONS);
            appName = attrs.getValue(ATTR_APPLICATION_NAME);
        }
    } finally {
        jf.close();
    }
    prj.log(
        String.format(
            "Application: %s manifest: Codebase: %s, Permissions: %s, Application-Name: %s",    //NOI18N
            safeRelativePath(prj.getBaseDir(), mainJar),
            codebase,
            permissions,
            appName),
        Project.MSG_VERBOSE);
    if (codebase != null || permissions != null || appName != null) {
        for (File library : libraries) {
            try {
                extendLibraryManifest(prj, library, codebase, permissions, appName);
            } catch (ManifestException mex) {
                throw new IOException(mex);
            }
        }
    }
}
ZipHelper.java 文件源码 项目:ChronoBike 阅读 31 收藏 0 点赞 0 评论 0
/**
* Zips the specified file.
* @param file The file to archive.
* @param destinationZipArchive Specifies the zip archive where to store the specified 
* file. If the zip archive already exists, it is deleted before starting
* the process. Folders and subfolders are created if needed. If the specified file
* already exists and it is a folder, an exception is raised.
* @param moveFile If <i>true</i> the specified file is deleted from its original
* location after the zip archive has been successfully created.
*/
public static void zipFile(File file,File destinationZipArchive,boolean moveFile) throws Exception {
    try {
        ArrayList<File> list=new ArrayList<File>();
        list.add(file);
        zipFiles(list,destinationZipArchive,moveFile);
    }
    catch  (Exception e) {
        String sFile="null";
        if (file!=null) sFile=file.getAbsolutePath();
        String sDestinationZipArchive="null";
        if (destinationZipArchive!=null) sDestinationZipArchive=destinationZipArchive.getAbsolutePath();
        throw new Exception(ParseError.parseError("ZipHelper.zipFile('"+sFile+"','"+sDestinationZipArchive+"',"+moveFile,e));
    }
}
WavCreator.java 文件源码 项目:Explorium 阅读 22 收藏 0 点赞 0 评论 0
public void generateWavFile(String path) throws Exception {
    long numFrames = (long)(duration * SoundGenerator.sampleRate());
    WavFile wfile = WavFile.newWavFile(new File(path), 1, numFrames, 16, SoundGenerator.sampleRate());
       double[][] tempbuffer = new double[1][100];
       Iterator<Double> ite = buffer.iterator();

       // Initialise a local frame counter
       while(ite.hasNext()) {
        int i = 0;
        int toWrite = (wfile.getFramesRemaining() > tempbuffer[0].length) ? tempbuffer[0].length : (int) wfile.getFramesRemaining();
        // Loop until all frames written
        while (ite.hasNext() && (i < toWrite)){
            tempbuffer[0][i] = (double) ite.next();
            i++;
        }
        wfile.writeFrames(tempbuffer, toWrite);
        if(wfile.getFramesRemaining() == 0)
            break;
       }

       // Close the wavFile
       wfile.close();
}
PythonGenericClassifier.java 文件源码 项目:StackNet 阅读 27 收藏 0 点赞 0 评论 0
/**
  * 
  * @param confingname : full path and name of the config file
  */
 private void create_light_suprocess(String confingname ) {

  // check if file exists
  if (new File(confingname).exists()==false){
   throw new IllegalStateException("Config file does not exist at: " + confingname);
  }
  // create the subprocess
try {

     String python_path="python";
     String s_path="lib" + File.separator + "python" + File.separator +  this.script_name.replace(".py", this.index+".py");
     List<String> list = new ArrayList<String>();
     list.add(python_path); 
     list.add(s_path);               
     list.add( confingname); 

     //start the process         
     ProcessBuilder p = new ProcessBuilder(list);         
     p.redirectErrorStream(true);
     Process sp = p.start();
     BufferedReader r = new BufferedReader(new InputStreamReader(sp.getInputStream()));
     String line;
        while(true){
            line = r.readLine();
            if(line == null) { break; }
            if (this.verbose){
                System.out.println(line);
            }
        }

} catch (IOException e) {
    throw new IllegalStateException(" failed to create sklearn subprocess with config name " + confingname);
}

 }
FreeColDirectories.java 文件源码 项目:FreeCol 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Gets the save game files in a given directory.
 *
 * @param directory The base directory, or the default locations if null.
 * @return A stream of save game {@code File}s.
 */
public static Stream<File> getSavegameFiles(File directory) {
    return (directory == null)
        ? flatten(Stream.of(FreeColDirectories.getSaveDirectory(),
                            FreeColDirectories.getAutosaveDirectory()),
                  d -> fileStream(d, saveGameFilter))
        : fileStream(directory, saveGameFilter);
}
MavenBinaryForSourceQueryImplTest.java 文件源码 项目:incubator-netbeans 阅读 25 收藏 0 点赞 0 评论 0
public void testResources() throws Exception { // #208816
    TestFileUtils.writeFile(d,
            "pom.xml",
            "<project xmlns='http://maven.apache.org/POM/4.0.0'>" +
            "<modelVersion>4.0.0</modelVersion>" +
            "<groupId>grp</groupId>" +
            "<artifactId>art</artifactId>" +
            "<packaging>jar</packaging>" +
            "<version>0</version>" +
            "</project>");
    FileObject res = FileUtil.createFolder(d, "src/main/resources");
    FileObject tres = FileUtil.createFolder(d, "src/test/resources");
    CharSequence log = Log.enable(BinaryForSourceQuery.class.getName(), Level.FINE);
    File repo = EmbedderFactory.getProjectEmbedder().getLocalRepositoryFile();
    File art0 = new File(repo, "grp/art/0/art-0.jar");
    URL url0 = FileUtil.getArchiveRoot(art0.toURI().toURL()); 

    assertEquals(Arrays.asList(new URL(d.toURL(), "target/classes/"), url0), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(res.toURL()).getRoots()));
    assertEquals(Arrays.asList(new URL(d.toURL(), "target/test-classes/"), url0), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(tres.toURL()).getRoots()));
    String logS = log.toString();
    assertFalse(logS, logS.contains("-> nil"));
    assertTrue(logS, logS.contains("ProjectBinaryForSourceQuery"));
}
ArchiveService.java 文件源码 项目:osc-core 阅读 28 收藏 0 点赞 0 评论 0
private Query getCallableStatementTask(EntityManager em, Timestamp sqlTimeString, String dir) throws SQLException {
    File cvsFile = new File(dir + "task.csv");
    Query spq = em.createNativeQuery("{CALL CSVWRITE(?, ?, ?)}");
    spq.setParameter(1, String.valueOf(cvsFile.getAbsoluteFile()));
    spq.setParameter(2, "SELECT * FROM TASK WHERE job_fk IN (SELECT ID FROM JOB WHERE completed_timestamp <= '"+sqlTimeString+"')");
    spq.setParameter(3,"charset=UTF-8 fieldSeparator=,");
    return spq;
}
FileSystemDataStore.java 文件源码 项目:dhus-core 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Generates a zip file.
 *
 * @param source      source file or directory to compress.
 * @param destination destination of zipped file.
 * @return the zipped file.
 */
private void generateZip (File source, File destination) throws IOException
{
   if (source == null || !source.exists ())
   {
      throw new IllegalArgumentException ("source file should exist");
   }
   if (destination == null)
   {
      throw new IllegalArgumentException (
            "destination file should be not null");
   }

   FileOutputStream output = new FileOutputStream (destination);
   ZipOutputStream zip_out = new ZipOutputStream (output);
   zip_out.setLevel (
         cfgManager.getDownloadConfiguration ().getCompressionLevel ());

   List<QualifiedFile> file_list = getFileList (source);
   byte[] buffer = new byte[BUFFER_SIZE];
   for (QualifiedFile qualified_file : file_list)
   {
      ZipEntry entry = new ZipEntry (qualified_file.getQualifier ());
      InputStream input = new FileInputStream (qualified_file.getFile ());

      int read;
      zip_out.putNextEntry (entry);
      while ((read = input.read (buffer)) != -1)
      {
         zip_out.write (buffer, 0, read);
      }
      input.close ();
      zip_out.closeEntry ();
   }
   zip_out.close ();
   output.close ();
}
WorkspaceSetupTest.java 文件源码 项目:n4js 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Returns test data.
 */
@Parameters(name = "{0}")
public static Collection<Object[]> data() throws Exception {
    File rootDir = findGitRepoRootDir();
    List<Object[]> result = Lists.newArrayList();
    collectProjects(rootDir, result);
    return result;
}
LocalHistory.java 文件源码 项目:incubator-netbeans 阅读 31 收藏 0 点赞 0 评论 0
public static void logFile(String msg, File file) {
    if(!LOG.isLoggable(Level.FINE)) {
        return;
    }        
    StringBuilder sb = new StringBuilder();        
    sb.append(msg);
    sb.append('\t');
    sb.append(file.getAbsolutePath());            
    log(sb.toString()); 
}
AbstractIntegrationTest.java 文件源码 项目:arez 阅读 34 收藏 0 点赞 0 评论 0
private void saveIfOutputEnabled( @Nonnull final Path file, @Nonnull final String contents )
  throws IOException
{
  if ( outputFiles() )
  {
    final File dir = file.getParent().toFile();
    if ( !dir.exists() )
    {
      assertTrue( dir.mkdirs() );
    }
    Files.write( file, ( contents + "\n" ).getBytes() );
  }
}
ScanDirConfig.java 文件源码 项目:jdk8u-jdk 阅读 50 收藏 0 点赞 0 评论 0
static String guessConfigName(String configFileName,String defaultFile) {
    try {
        if (configFileName == null) return DEFAULT;
        final File f = new File(configFileName);
        if (f.canRead()) {
            final String confname = XmlConfigUtils.read(f).getName();
            if (confname != null && confname.length()>0) return confname;
        }
        final File f2 = new File(defaultFile);
        if (f.equals(f2)) return DEFAULT;
        final String guess = getBasename(f.getName());
        if (guess == null) return DEFAULT;
        if (guess.length()==0) return DEFAULT;
        return guess;
    } catch (Exception x) {
        return DEFAULT;
    }
}
NbModuleProjectGeneratorTest.java 文件源码 项目:incubator-netbeans 阅读 23 收藏 0 点赞 0 评论 0
public void testCreateStandAloneModule() throws Exception {
    File targetPrjDir = new File(getWorkDir(), "testModule");
    NbModuleProjectGenerator.createStandAloneModule(
            targetPrjDir,
            "org.example.testModule", // cnb
            "Testing Module", // display name
            "org/example/testModule/resources/Bundle.properties",
            "org/example/testModule/resources/layer.xml",
            NbPlatform.PLATFORM_ID_DEFAULT, false, true); // platform id
    FileObject fo = FileUtil.toFileObject(targetPrjDir);
    // Make sure generated files are created too - simulate project opening.
    NbModuleProject p = (NbModuleProject) ProjectManager.getDefault().findProject(fo);
    assertNotNull("have a project in " + targetPrjDir, p);
    p.open();
    // check generated module
    for (int i=0; i < BASIC_CREATED_FILES.length; i++) {
        assertNotNull(BASIC_CREATED_FILES[i]+" file/folder cannot be found",
                fo.getFileObject(BASIC_CREATED_FILES[i]));
    }
    for (int i=0; i < STANDALONE_CREATED_FILES.length; i++) {
        assertNotNull(STANDALONE_CREATED_FILES[i]+" file/folder cannot be found",
                fo.getFileObject(STANDALONE_CREATED_FILES[i]));
    }
}
WsimportOptions.java 文件源码 项目:OpenJSharp 阅读 30 收藏 0 点赞 0 评论 0
private InputSource absolutize(InputSource is) {
    // absolutize all the system IDs in the input,
    // so that we can map system IDs to DOM trees.
    try {
        URL baseURL = new File(".").getCanonicalFile().toURL();
        is.setSystemId(new URL(baseURL, is.getSystemId()).toExternalForm());
    } catch (IOException e) {
        // ignore
    }
    return is;
}


问题


面经


文章

微信
公众号

扫码关注公众号