Reading ASCII Character from buffer
807569Aug 7 2006 — edited Aug 8 2006Hi,
I have problem in reading a series of ascii code obtained from the byte buffer. Below is the extract of the programme
The programme initially skip the first 192 bytes of the inputfile, proceed to read into the Buffer the next 192 bytes.
Using the ByteArrayInputStream declared as byteAS, the block of character needed to be read is from 33 to 38
I can only read the first character located at 32 using .skipBytes(32) but I do not know how to read the next block of characters at location 33 and there after .
All the bytes stored in the Buffer can in fact be read one after another but to convert them into character string?
I have heard of java.nio.* , but got very confuse about the unicode and character conversion.
Any help please?
Thnak you
***********************************************************************************
import java.util.*;
import java.io.*;
import java.io.DataInputStream.*;
import java.nio.*;
import java.math.*;
import java.lang.*;
public class msread {
private DataInputStream in=null;
public msread(String file) throws Exception {
BufferedInputStream in1=null;
in=new DataInputStream(new FileInputStream(file));
long length=file.length();
byte[] Buf=null;
int buflen=192;
Buf=new byte[buflen];
Short sval=0;
System.out.println("File Length-->"+length);
in.skipBytes(192);
in.read(Buf);
ByteArrayInputStream byteAS=new ByteArrayInputStream(Buf);
DataInputStream din=new DataInputStream(byteAS);
din.skipBytes(31);
System.out.println("DATA 01-->"+din.readChar());
din.skipBytes(32)
System.out.println("DATA 02-->"+din.readChar());
----------