Read short from file using DataInputStream
import
java.io.DataInputStream;
import java.io.FileInputStream;
import
java.io.FileNotFoundException;
import
java.io.IOException;
public class
ReadShortFromFile
{
public static void
main(String[] args)
{
String
strFilePath = "C://FileIO//readShort.txt";
try
{
FileInputStream fin =
new FileInputStream(strFilePath);
DataInputStream din =
new DataInputStream(fin);
short s =
din.readShort();
System.out.println("short
: " + s);
din.close();
}
catch(FileNotFoundException
fe)
{
System.out.println("FileNotFoundException
: " + fe);
}
catch(IOException ioe)
{
System.out.println("IOException
: " + ioe);
}
}
}
No comments:
Post a Comment