Buggy code:
public class Functions { private static long lastId ; public static String MUSIC_FOLDER_PATH ; public static File MUSIC_FOLDER ; public static String USER ; public static long generateNextId ( ) { } public static final SimpleDateFormat FORMAT_DATE = new SimpleDateFormat ( "yyyy-MM-dd" ) ; public static final SimpleDateFormat FORMAT_DATE_TIME = new SimpleDateFormat ( "yyyy-MM-dd<seq2seq4repair_space>HH:mm:ss" ) ; public static final SimpleDateFormat FORMAT_MONTH = new SimpleDateFormat ( "yyyy-MM" ) ; public static String getDateTime ( ) { } public static String getDate ( ) { } public static String getMonth ( ) { } public static final FileFilter FILTER_MUSIC = new FileFilter ( ) { @ Override public boolean accept ( File arg0 ) { } } ; public static final FileFilter FILTER_FOLDER = new FileFilter ( ) { @ Override public boolean accept ( File arg0 ) { } } ; public static final FileFilter FILTER_JSON = new FileFilter ( ) { @ Override public boolean accept ( File arg0 ) { } } ; public static final FileFilter FILTER_M3U = new FileFilter ( ) { @ Override public boolean accept ( File arg0 ) { } } ; public static final Functions . VariableFileNameFilter FILTER_VARIABLE_NAME = new Functions . VariableFileNameFilter ( ) ; public static final DefaultTableCellRenderer STRING_RENDERER = new DefaultTableCellRenderer ( ) { private static final long serialVersionUID = 6622568154463754357L ; @ Override public Component getTableCellRendererComponent ( JTable table , Object value , boolean isSelected , boolean hasFocus , int row , int column ) { } } ; public static String cleanSpacesAtEnd ( String str ) { } private static int indexOfSpace ( String str ) { } public static String getDigitFormat ( int digits ) { } public static synchronized int getDigits ( int size ) { } public static String formatNumber ( int digits , int number ) { } public static String cleanString ( String string ) { } public static boolean isWindows ( ) { } public static String formatPlaylistPath ( String fileName ) { } public static String makeRelative ( String fileName ) { } public static String makeAbsolute ( String fileName ) { } public static String makeAnyPathRelative ( String fileName ) { } private static String makeRelativeTo ( Folders folder , String fileName ) { } public static String writeStringToFile ( File folder , String fileName , String fileExtension , String content , boolean overwrite , boolean addUserName ) throws MusicException { folder . mkdirs ( ) ; String date = Functions . getDate ( ) ; int i = 1 ; File file ; String fileNameTrunk ; if ( addUserName ) { fileNameTrunk = ( ( ( ( fileName + ( Constants . M3U_DASH ) ) + ( Functions . USER ) ) + ( Constants . SPACE_STRING ) ) + date ) + ( Constants . SPACE_STRING ) ; } else { fileNameTrunk = ( ( fileName + ( Constants . SPACE_STRING ) ) + date ) + ( Constants . SPACE_STRING ) ; } file = new File ( folder , ( ( ( ( fileNameTrunk + ( Constants . LEFT_BRACE ) ) + ( Functions . formatNumber ( DEFAULT_DIGITS , i ) ) ) + ( Constants . RIGHT_BRACE ) ) + fileExtension ) ) ; if ( ! overwrite ) { while ( file . exists ( ) ) { i ++ ; file = new File ( folder , ( ( ( ( fileNameTrunk + ( Constants . LEFT_BRACE ) ) + ( Functions . formatNumber ( DEFAULT_DIGITS , i ) ) ) + ( Constants . RIGHT_BRACE ) ) + fileExtension ) ) ; } } try { <START_BUG> PrintWriter writer = new PrintWriter ( new OutputStreamWriter ( new FileOutputStream ( file ) ) ) ; <END_BUG> writer . write ( content ) ; writer . close ( ) ; } catch ( FileNotFoundException e ) { throw new MusicException ( Type . FILE_NOT_FOUND , fileName , e ) ; } return file . getAbsolutePath ( ) ; } public static String readStringFromFile ( File file ) throws MusicException { } public static List < String > readStringListFromFile ( File file ) throws MusicException { } public static class VariableFileNameFilter implements FileFilter { private String name ; private VariableFileNameFilter ( ) { } @ Override public boolean accept ( File arg0 ) { } public void setName ( String name ) { } public String getName ( ) { } } public static String listFilesAsString ( List < File > fileList ) { } public static String formatTime ( int res ) { } public static int cleanNumber ( String number ) { } }

Fix:
PrintWriter writer = new PrintWriter ( new OutputStreamWriter ( new FileOutputStream ( file ) , Constants . DEFAULT_ENCODING ) ) ;