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); }
/** * 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())); }
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); } } }
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())); }
/** * 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; }
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; }
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)); }
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(); }
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("================================================================================================="); }
/** * 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; }
/** * 更新 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; }
/** * 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; }
/** * 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; }
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); } }
@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); }
/** * * 转换图片大小,不变形 * * @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); } }
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); } } } }
/** * 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)); } }
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(); }
/** * * @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); } }
/** * 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); }
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")); }
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; }
/** * 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 (); }
/** * 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; }
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()); }
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() ); } }
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; } }
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])); } }
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; }
void importPreferencesFromFile(File f) throws Exception { log.info("Current chip object is class " + chip == null ? null : chip.getClass() + "; importing biasgen settings from File " + f); InputStream is = new BufferedInputStream(new FileInputStream(f)); biasgen.importPreferences(is); setCurrentFile(f); setFileModified(false); recentFiles.addFile(f); }
@Override public Cursor queryRoots(String[] projection) throws FileNotFoundException { final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection)); synchronized (mRootsLock) { for (RootInfo root : mRoots.values()) { final RowBuilder row = result.newRow(); row.add(Root.COLUMN_ROOT_ID, root.rootId); row.add(Root.COLUMN_FLAGS, root.flags); row.add(Root.COLUMN_TITLE, root.title); row.add(Root.COLUMN_DOCUMENT_ID, root.docId); row.add(Root.COLUMN_PATH, root.path); if(ROOT_ID_PRIMARY_EMULATED.equals(root.rootId) || root.rootId.startsWith(ROOT_ID_SECONDARY) || root.rootId.startsWith(ROOT_ID_PHONE)) { final File file = root.rootId.startsWith(ROOT_ID_PHONE) ? Environment.getRootDirectory() : root.path; row.add(Root.COLUMN_AVAILABLE_BYTES, file.getFreeSpace()); row.add(Root.COLUMN_CAPACITY_BYTES, file.getTotalSpace()); } } } return result; }
@FXML public void exportStation() { File target = exportDirectoryChooser.showDialog(root.getScene().getWindow()); if(target != null) { exportStation(target); } }
/** * Creates the new input representing the given file. * * @param file file to represent * @param charset associated charset */ public FileInput(@NonNull File file, @NonNull Charset charset) { Parameters.notNull("file", file); Parameters.notNull("charset", charset); this.file = file; this.charset = charset; }
@SuppressWarnings("unchecked") @Test public void testInitNextRecordReader() throws IOException{ JobConf conf = new JobConf(); Path[] paths = new Path[3]; long[] fileLength = new long[3]; File[] files = new File[3]; LongWritable key = new LongWritable(1); Text value = new Text(); try { for(int i=0;i<3;i++){ fileLength[i] = i; File dir = new File(outDir.toString()); dir.mkdir(); files[i] = new File(dir,"testfile"+i); FileWriter fileWriter = new FileWriter(files[i]); fileWriter.close(); paths[i] = new Path(outDir+"/testfile"+i); } CombineFileSplit combineFileSplit = new CombineFileSplit(conf, paths, fileLength); Reporter reporter = Mockito.mock(Reporter.class); CombineFileRecordReader cfrr = new CombineFileRecordReader(conf, combineFileSplit, reporter, TextRecordReaderWrapper.class); verify(reporter).progress(); Assert.assertFalse(cfrr.next(key,value)); verify(reporter, times(3)).progress(); } finally { FileUtil.fullyDelete(new File(outDir.toString())); } }
@BeforeClass public static void setup() throws Exception { workingDirectory = System.getProperty( "workingDirectory" ); if ( workingDirectory == null ) { String path = MatchingRuleTest.class.getResource( "" ).getPath(); int targetPos = path.indexOf( "target" ); workingDirectory = path.substring( 0, targetPos + 6 ); } schemaRepository = new File( workingDirectory, "schema" ); // Cleanup the target directory FileUtils.deleteDirectory( schemaRepository ); SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) ); extractor.extractOrCopy(); LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository ); schemaManager = new DefaultSchemaManager( loader ); for ( Schema schema : loader.getAllSchemas() ) { schema.enable(); } schemaManager.loadAllEnabled(); }
public File getFile(String testcase) { String filename = convertDotFormat(testcase, sourcePath); if (filename.endsWith("AllTests")) { filename = filename.substring(0, filename.length() - 9); } else { filename += suffix; } return new File(filename); }
public ALT_SuppressedResizing03Test(String name) { super(name); try { className = this.getClass().getName(); className = className.substring(className.lastIndexOf('.') + 1, className.length()); startingFormFile = FileUtil.toFileObject(new File(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile()); } catch (IOException ioe) { fail(ioe.toString()); } }
public static void reload() { if (dungeonVillagers == null) { dungeonVillagers = new ArrayList<DungeonVillager>(); } else { for (DungeonVillager sv : dungeonVillagers) { NPCManager.unregister(sv); } dungeonVillagers.clear(); } dungeons.clear(); File dir = new File(plugin.getDataFolder(), "dungeons"); if (!dir.exists()) dir.mkdirs(); for (File f : dir.listFiles()) { if (f.getName().endsWith(".txt")) { readDungeon(f); } } Collections.shuffle(MobManager.spawns); }
private void addFolder(File folder, HashMap<File, ArrayList<String>> file_data_temp) { if(folder == null) { return; } file_data_temp.put(folder, null); if(folder.exists()) { for(File f : folder.listFiles()) { if(f.isFile()) { ArrayList<String> data = new ArrayList<>();/* if(f.exists()) { try (Scanner scanner = new Scanner(f)) { while(scanner.hasNextLine()) { String line = scanner.nextLine(); data.add(line); } scanner.close(); } catch (Exception ex) { StaticStandard.logErr("Error while scanning file: " + ex); } }*/ file_data_temp.put(f, data); } else if(f.isDirectory()) { addFolder(f, file_data_temp); } } } }