Skip to content

Commit

Permalink
try with resources (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Jul 17, 2020
1 parent b42cd5a commit b974fb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
Expand Up @@ -37,7 +37,6 @@
import org.apache.maven.plugins.resources.stub.MavenProjectResourcesStub;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.eclipse.aether.RepositorySystemSession;

public class ResourcesMojoTest
Expand Down Expand Up @@ -691,18 +690,9 @@ private void assertContent( String fileName, String data )
throws IOException
{
assertTrue( FileUtils.fileExists( fileName ) );

BufferedReader reader = null;
try
try( BufferedReader reader = new BufferedReader( new FileReader( fileName ) ) )
{
reader = new BufferedReader( new FileReader( fileName ) );
assertEquals( data, reader.readLine() );
reader.close();
reader = null;
}
finally
{
IOUtil.close( reader );
}
}

Expand Down
Expand Up @@ -240,7 +240,7 @@ private void createDirectories( String parent, String testparent )
}
}

private void createFiles( String parent, String testparent )
private void createFiles( String parent, String testparent ) throws IOException
{
File currentFile;

Expand Down Expand Up @@ -278,15 +278,8 @@ private void createFiles( String parent, String testparent )

if ( !currentFile.exists() )
{
try
{
currentFile.createNewFile();
populateFile( currentFile );
}
catch ( IOException io )
{
//TODO: handle exception
}
currentFile.createNewFile();
populateFile( currentFile );
}
}
}
Expand All @@ -300,8 +293,6 @@ private void populateFile( File file ) throws IOException
try ( FileOutputStream outputStream = new FileOutputStream( file ) )
{
outputStream.write( data.getBytes() );
outputStream.flush();
outputStream.close();
}
}
}
Expand Down

0 comments on commit b974fb2

Please sign in to comment.