redirecting data to a text file

hi can anyone tel me how to redirect data coming from modem to a text file.I am able to view the sms coming to my modem i want those sms to store in a text file. please help me.Ramya
[203 byte] By [uramyajyothia] at [2007-10-3 9:18:13]
# 1

This is assumes you read a Byte Stream from your modem:

FileOutputStream file = new FileOutputStream(new File("modem.txt"));

byte data = // read from modem output stream

file.write(data);

watertownjordana at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 2
There is more then one way to do this, but this si the short and skinny version.
watertownjordana at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 3
hey i have some more doubts if i want to access a variable present in the sendData() method of Transmitter.java class of black package where sendData() is declared private then how to use the variable of that method in main class.?
uramyajyothia at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 4
If I understand this correctly, you can't. Any variable declared in a method is only accessible from within that method, in fact it only exists while the method is running. The method's access modifiers have nothing to do with it.
ejpa at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 5

This is assumes you read a Byte Stream from your modem:

FileOutputStream file = new FileOutputStream(new File("modem.txt"));

byte data = // read from modem output stream

file.write(data);

in my program string variable is taking those messages.Then how to store that data.If i am typing the above code i am getting errors.

also file.write(data); is this correct.can anyone tel me any alternative code.

FileOutputStream file = new FileOutputStream(new File("modem.txt"));

String data = // wat to do here ? // read from modem output stream

file.write(data); // and here i am getting some syntax error.

uramyajyothia at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 6
hey please some one help me.I am really not getting this.i have to redirect the data coming from modem to a text file.The data is getting into a string variable.In files how to handle the string data and store it in my file.
uramyajyothia at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 7
ejp: This guy doesn't understand programming logic and Java, I don't think we can help him except to suggest he buy a "..for Dummies" book.
watertownjordana at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 8
if u want to help me ok help me .Otherwise just dont reply.U need not comment on me.
uramyajyothia at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 9
I suggest you read the Javadoc for all the java.io classes before you go any further.
ejpa at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 10
plz tell me how to redirect data to text file
screendiptya at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...
# 11

it looks like u want to pass string data to write() function which accpets bytes?

if my assumption is write then u can use like

FileOutputStream fos = new FileOutputStream(new File("C:/test.txt"));

String data = "modem data";

fos.write(data.getBytes());

Its very basic java code,isn't?

kishore25a at 2007-7-15 4:31:15 > top of Java-index,Archived Forums,Socket Programming...