I'm trying to read a character from an input file, translate it to hex and write the hex characters to an output file. Any suggestions?
What I have so far
import java.io.*;
class TrivialApplication
{ public static void main(
String args[])
{
int i;
String inf = "p3in.txt";
String ouf = "pout.txt";
FileInputStream fin;
FileOutputStream fou;
try
{ fin = new FileInputStream(inf);//set up input file
}
catch(FileNotFoundException fnf)
{ System.out.println(inf);
return;
}
try
{ fou = new FileOutputStream(ouf);//set up output file
}
catch(FileNotFoundException fnf)
{ System.out.println(fnf);
return;
}
try
{
do
{
i = fin.read(); //read a char in; write a char out
if(i != -1)
{
???;
fou.write(?);
}
}
while(i != -1);
}
catch(IOException ioe)
{ System.out.println("File error");
}
fin.close();
fou.close();
}
}