l**t 发帖数: 452 | 1 urgent!
how to output the first 5 letters to a file from a 20-letter string?
thank you!!! |
xt 发帖数: 17532 | 2
OutputStream out = ...;
String str = ...;
byte[] b = str.getBytes();
out.write( b, 0, 5 );
【在 l**t 的大作中提到】 : urgent! : how to output the first 5 letters to a file from a 20-letter string? : thank you!!!
|
c*****t 发帖数: 1879 | 3 why not using substring?
【在 xt 的大作中提到】 : : OutputStream out = ...; : String str = ...; : byte[] b = str.getBytes(); : out.write( b, 0, 5 );
|
m**c 发帖数: 90 | 4
String str20 = ...;
Writer writer = new BufferedWriter(new FileWriter(new File(...)));
write.write (str20, 0, 5); // cannot remember it should 4 or 5
writer.close();
【在 c*****t 的大作中提到】 : why not using substring?
|
st 发帖数: 1685 | 5
~~~~~~~~no need to
nest one more bah.
BufferedWriter w=new BufferedWriter(new FileWriter("filename")); should work.
【在 m**c 的大作中提到】 : : String str20 = ...; : Writer writer = new BufferedWriter(new FileWriter(new File(...))); : write.write (str20, 0, 5); // cannot remember it should 4 or 5 : writer.close();
|
c*****t 发帖数: 1879 | 6 ffdt, use
str20.substring (0, 5)
【在 m**c 的大作中提到】 : : String str20 = ...; : Writer writer = new BufferedWriter(new FileWriter(new File(...))); : write.write (str20, 0, 5); // cannot remember it should 4 or 5 : writer.close();
|