From cfd0c0679e5619c80a08d668bba50b73b99fcff4 Mon Sep 17 00:00:00 2001 From: 0xc0d3r Date: Wed, 20 Aug 2014 22:13:29 +0530 Subject: [PATCH] space added in utilmethods.java --- src/util/UtilMethods.java | 2 +- src/util/UtilMethods.java~ | 78 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/util/UtilMethods.java~ diff --git a/src/util/UtilMethods.java b/src/util/UtilMethods.java index 27c857d..23ac342 100644 --- a/src/util/UtilMethods.java +++ b/src/util/UtilMethods.java @@ -27,7 +27,7 @@ public static String getFileData(String fname) { } catch(Exception e) { throw new RuntimeException("ERROR: File operation failed.@UtilMethods.java_getFileData()"); - //System.out.println("ERROR: File operation failed.@UtilMethods.java_getFileData()"); + //System.out.println("ERROR: File operation failed. @UtilMethods.java_getFileData()"); } return text; } diff --git a/src/util/UtilMethods.java~ b/src/util/UtilMethods.java~ new file mode 100644 index 0000000..27c857d --- /dev/null +++ b/src/util/UtilMethods.java~ @@ -0,0 +1,78 @@ +package stegtool.util; +import java.io.FileInputStream; +import java.io.File; +import java.io.InputStream; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.FileWriter; +import java.io.BufferedWriter; +import java.awt.Color; + +import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; +public class UtilMethods { + + //to get contents of a text file + public static String getFileData(String fname) { + String text = ""; + int ch; + try { + InputStream is = new FileInputStream(fname); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + while( (ch = br.read()) != -1 ) { + text += ""+(char)ch; + } + } + catch(Exception e) { + throw new RuntimeException("ERROR: File operation failed.@UtilMethods.java_getFileData()"); + //System.out.println("ERROR: File operation failed.@UtilMethods.java_getFileData()"); + } + return text; + } + + public static void setFileData(String name,String data) { + try { + File file = new File(name); + FileWriter fw = new FileWriter(file); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(data); + bw.close(); + } + catch(IOException e) { + throw new RuntimeException("\nError: Couldn't write data to file. UtilMethods.java@setFileData()."); + //System.out.println("\nError: Couldn't write data to file. UtilMethods.java@setFileData()."); + } + } + + //to get binary format of given string + public static String textToBinary(String text) { + String bin = ""; + StringBuffer sb = null; + for(int i=0;i