Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache JMeter
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.jmeter.services
Class FileServer

    java.lang.Object
      org.apache.jmeter.services.FileServer

public class FileServer
extends Object

The point of this class is to provide thread-safe access to files, and to provide some simplifying assumptions about where to find files and how to name them. For instance, putting supporting files in the same directory as the saved test plan file allows users to refer to the file with just it's name - this FileServer class will find the file without a problem. Eventually, I want all in-test file access to be done through here, with the goal of packaging up entire test plans as a directory structure that can be sent via rmi to remote servers (currently, one must make sure the remote server has all support files in a relative-same location) and to package up test plans to execute on unknown boxes that only have Java installed.

Method Summary
`void` | `closeFile(String name)`
`void` | `closeFiles()`
`protected boolean` | `filesOpen()`
`String` | `getBaseDir()`
`static FileServer` | `getFileServer()`
`File` | `getRandomFile(String basedir, String[] extensions)` Method will get a random file in a base directory TODO hey, not sure this method belongs here.
`String` | `readLine(String filename)` Get the next line of the named file, recycle by default.
`String` | `readLine(String filename, boolean recycle)` Get the next line of the named file.
`void` | `reserveFile(String filename)` Creates an association between a filename and a File inputOutputObject, and stores it for later use - unless it is already stored.
`void` | `reserveFile(String filename, String charsetName)` Creates an association between a filename and a File inputOutputObject, and stores it for later use - unless it is already stored.
`void` | `reserveFile(String filename, String charsetName, String alias)` Creates an association between a filename and a File inputOutputObject, and stores it for later use - unless it is already stored.
`void` | `resetBase()`
`void` | `setBasedir(String basedir)`
`void` | `write(String filename, String value)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getFileServer

    public static FileServer getFileServer()

### resetBase

    public void resetBase()
                   throws IOException

  Throws:
    `IOException`

### setBasedir

    public void setBasedir(String basedir)
                    throws IOException

  Throws:
    `IOException`

### getBaseDir

    public String getBaseDir()

### reserveFile

    public void reserveFile(String filename)

  Creates an association between a filename and a File inputOutputObject, and stores it for later use - unless it is already stored.

  Parameters:
    `filename` - - relative (to base) or absolute file name (must not be null)

### reserveFile

    public void reserveFile(String filename,
                            String charsetName)

  Creates an association between a filename and a File inputOutputObject, and stores it for later use - unless it is already stored.

  Parameters:
    `filename` - - relative (to base) or absolute file name (must not be null)
    `charsetName` - - the character set encoding to use for the file (may be null)

### reserveFile

    public void reserveFile(String filename,
                            String charsetName,
                            String alias)

  Creates an association between a filename and a File inputOutputObject, and stores it for later use - unless it is already stored.

  Parameters:
    `filename` - - relative (to base) or absolute file name (must not be null)
    `charsetName` - - the character set encoding to use for the file (may be null)
    `alias` - - the name to be used to access the object (must not be null)

### readLine

    public String readLine(String filename)
                    throws IOException

  Get the next line of the named file, recycle by default.

  Parameters:
    `filename` -
  Returns:
    String containing the next line in the file
  Throws:
    `IOException`

### readLine

    public String readLine(String filename,
                           boolean recycle)
                    throws IOException

  Get the next line of the named file.

  Parameters:
    `filename` -
    `recycle` - - should file be restarted at EOF?
  Returns:
    String containing the next line in the file (null if EOF reached and not recycle)
  Throws:
    `IOException`

### write

    public void write(String filename,
                      String value)
               throws IOException

  Throws:
    `IOException`

### closeFiles

    public void closeFiles()
                    throws IOException

  Throws:
    `IOException`

### closeFile

    public void closeFile(String name)
                   throws IOException

  Parameters:
    `name` -
  Throws:
    `IOException`

### filesOpen

    protected boolean filesOpen()

### getRandomFile

    public File getRandomFile(String basedir,
                              String[] extensions)

  Method will get a random file in a base directory TODO hey, not sure this method belongs here. FileServer is for threadsafe File access relative to current test's base directory.

  Parameters:
    `basedir` -
  Returns:
    a random File from the basedir that matches one of the extensions

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache JMeter
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1998-2009 Apache Software Foundation. All Rights Reserved.