Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to use the read () method of InputSteam to directly read the characters in the source code? Pray for the gods.
How to use the read () method of InputSteam to directly read the characters in the source code? Pray for the gods.
string str = " "+file inputstream . read(); Your instruction can only get the plastic expression value of a single character.

Just give the reference code and change the reading part to mine:

Public static void main(String[] args) {

File io _ Fil = new File(" E:\ \ Java \ \ study \ \ src \ \ io _ File . txt ");

Try {

file inputstream file inputstream = new file inputstream(io _ Fil);

Try {

byte b[]= new byte[(int)io _ fil . length()]; //The array size is determined by the file.

int len = file inputstream . read(b); //Reading content

system . out . println(" content:"+new String(b));

file inputstream . close();

} catch (IOException e) {

e . printstacktrace();

}

} catch(file not found exception e){

e . printstacktrace();

}

}

}