Question: I have a couple of methods which take filenames as parameters. My doubt is that what is better way to declare the parameters of these methods. 

* Should the parameter be of type `String`

```
void normalizeData(String inFile)

```
* Or should I explicitly declare the parameter as `File`.

```
void normalizeData(File inFile)

```

Personally I find `File` more intuitive but want to know about what is the best practice for such things.

Answer: 
I would pass an [`java.io.InputStream`](http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html) - this makes the code easier to test and doesn't bind it to the file system.

This way your code ends up like:

```
public void normalizeData(InputStream in)
{
  ...
}

```

And calling it:

```
myObject.normalizeData(new FileInputStream(myFile));

```

Or

```
myObject.normalizeData(new FileInputStream("c:/myfile.txt"));

```

Or in a test

```
myObject.normalizeData(new ByteArrayInputStream("some test data".getBytes()));

```
The design depends on many parameters, such as, who is going to use this method. Is it going to be overloaded, is it internal, package level or public API. I would tend to be general and offer two overloaded methods:

* one which passes in the `Path` which is a common way of specifying the path to a file
* and one which passes in the `InputStream`, i.e. general representation of input stream of bytes

public void normalizeData(Path filePath) //Path is a common way for specifying file path

public void normalizeData(InputStream) //general representation of input stream of bytes

But as I said, it depends on your project specification.