org.apache.jmeter.services.FileServer Java Examples
The following examples show how to use
org.apache.jmeter.services.FileServer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RandomCSVReader.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
public RandomCSVReader(String filename, String encoding, String delim, boolean randomOrder, boolean hasVariableNames, boolean firstLineIsHeader, boolean isRewindOnEndOfList) { File f = new File(filename); this.file = (f.isAbsolute() || f.exists()) ? f : new File(FileServer.getFileServer().getBaseDir(), filename); this.encoding = encoding; this.delim = checkDelimiter(delim).charAt(0); this.isSkipFirstLine = !(!firstLineIsHeader && hasVariableNames); this.randomOrder = randomOrder; this.isRewindOnEndOfList = isRewindOnEndOfList; try { initOffsets(); if (randomOrder) { initRandom(); } else { initConsistentReader(); } initHeader(); } catch (IOException ex) { LOGGER.error("Cannot initialize RandomCSVReader, because of error: ", ex); throw new RuntimeException("Cannot initialize RandomCSVReader, because of error: " + ex.getMessage(), ex); } }
Example #2
Source File: MergeResultsService.java From jmeter-plugins with Apache License 2.0 | 5 votes |
private static PrintWriter getFileWriter(String filename, SampleSaveConfiguration saveConfig) throws IOException { if (filename == null || filename.length() == 0) { return null; } filename = FileServer.resolveBaseRelativeName(filename); FileEntry fe = files.get(filename); PrintWriter writer; if (fe == null) { // Find the name of the directory containing the file // and create it - if there is one File pdir = new File(filename).getParentFile(); if (pdir != null) { // returns false if directory already exists, so need to check // again if (pdir.mkdirs()) { log.info("Folder " + pdir.getAbsolutePath() + " was created"); } // else if might have been created by another process so not a // problem if (!pdir.exists()) { log.warn("Error creating directories for " + pdir.toString()); } } writer = new PrintWriter(new OutputStreamWriter( new BufferedOutputStream(new FileOutputStream(filename)), SaveService.getFileEncoding("UTF-8")), SAVING_AUTOFLUSH); log.debug("Opened file: " + filename); files.put(filename, new FileEntry(writer, saveConfig)); } else { writer = fe.pw; } writeFileStart(writer, saveConfig); return writer; }