| Author |
Encryption
|
Shelly Biswal
Greenhorn
Joined: Sep 07, 2007
Posts: 17
|
|
Hi all, i urgently need help.... i need to write a program which will encrypt a string using a character mapping provided in a file. The input to your program will be a file which contains mapping for characters. For E.g. A D B R S H with this mapping if the string has an 'A' then it should be replaced by 'D' etc... I have to use java exception handling to handle any exceptions like "File not found","File format not correct", "No mapping Present" etc....
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24061
|
|
OK, so you've told us your assignment. Now you have to show us what you've done so far. If you haven't been able to start: reading in the data file would be a good first step! As with all programming: take little steps. Write the code to open a file, make sure it compiles, test it. Then add code to read a line and print it out. Make sure it compiles, and then test it. Then write a loop to read all the lines, and test that. Take it one step at a time, and it will be easy.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Shelly Biswal
Greenhorn
Joined: Sep 07, 2007
Posts: 17
|
|
I wrote the code everyting wrks fine except line /*1*/ - the output is always null dont know why.. pls explain ReadCharacterMapping.java
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24061
|
|
|
You're storing the data using String objects as keys in the map, but you're trying to look it up using Character objects -- different kinds of objects, so they aren't interchangeable. Instead of get(s.charAt(i)), use get(String.valueOf(s.charAt(i))) .
|
 |
 |
|
|
subject: Encryption
|
|
|