-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daz Jones
committed
Feb 18, 2013
1 parent
14bbe65
commit 28701a3
Showing
4 changed files
with
79 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
CrescentParts/src/com/cyanogenmod/settings/device/Utils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.cyanogenmod.settings.device; | ||
|
||
import android.util.Log; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.io.SyncFailedException; | ||
|
||
public class Utils | ||
{ | ||
private static final String TAG = "CrescentParts"; | ||
|
||
public static void writeValue(String parameter, int value) { | ||
FileOutputStream fos = null; | ||
try { | ||
fos = new FileOutputStream(new File(parameter)); | ||
fos.write(String.valueOf(value).getBytes()); | ||
fos.flush(); | ||
// fos.getFD().sync(); | ||
} catch (FileNotFoundException ex) { | ||
Log.w(TAG, "file " + parameter + " not found: " + ex); | ||
} catch (SyncFailedException ex) { | ||
Log.w(TAG, "file " + parameter + " sync failed: " + ex); | ||
} catch (IOException ex) { | ||
Log.w(TAG, "IOException trying to sync " + parameter + ": " + ex); | ||
} catch (RuntimeException ex) { | ||
Log.w(TAG, "exception while syncing file: ", ex); | ||
} finally { | ||
if (fos != null) { | ||
try { | ||
Log.w(TAG, "file " + parameter + ": " + value); | ||
fos.close(); | ||
} catch (IOException ex) { | ||
Log.w(TAG, "IOException while closing synced file: ", ex); | ||
} catch (RuntimeException ex) { | ||
Log.w(TAG, "exception while closing file: ", ex); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters