55import static org .junit .jupiter .api .Assertions .assertNull ;
66
77import java .io .File ;
8+ import java .io .FileOutputStream ;
89import java .io .IOException ;
910import java .io .InputStream ;
11+ import java .nio .charset .StandardCharsets ;
1012import java .nio .file .Files ;
1113import java .nio .file .Path ;
1214
@@ -25,10 +27,15 @@ void before(){
2527
2628 File createSmallTmpFile () throws IOException {
2729 File f = File .createTempFile ("flatFile" ,"txt" );
28- Files . writeString ( Path . of ( f . getAbsolutePath ()), aDNA );
30+ writeToFile ( aDNA , f );
2931 return f ;
3032 }
3133
34+ private void writeToFile (String aDNA , File f ) throws IOException {
35+ FileOutputStream fos = new FileOutputStream (f );
36+ fos .write (aDNA .getBytes (StandardCharsets .UTF_8 ));
37+ }
38+
3239 @ Test
3340 void flatFileRetrieve () throws IOException {
3441 File aDNAFile = createSmallTmpFile ();
@@ -66,7 +73,7 @@ void fileCanBeModifiedButCachedValueIsUnchanged() throws IOException{
6673 long originalLength = aDNAFile .length ();
6774
6875 // write new content to original file
69- Files . writeString ( Path . of ( aDNAFile . getAbsolutePath ()), aProtein );
76+ writeToFile ( aProtein , aDNAFile );
7077
7178 // retrieve from cache, is unchanged
7279 InputStream is = FlatFileCache .getInputStream ("key" );
0 commit comments