Can't write to multiple lines to file...please help

Hi all ,
The following is trying to write to message receive from UDP packets. The problems is data_output can only write a single line of message to the file "serverlog.txt". How can write multiple line of message to the file?
     private void processUDPPackets(SelectionKey selectionKey){
          DatagramChannel datagramChannel = (DatagramChannel) selectionKey.channel();
          try{
               file_output = new FileOutputStream("serverlog.txt");
               data_output = new DataOutputStream(file_output);
               while(datagramChannel.receive(byteBuf) != null) {
                    byteBuf.flip();
                    charBuf = decoder.decode(byteBuf);
                    data_output.writeChars(charBuf.toString());
                    data_output.writeChars("\n");
                    byteBuf.clear();
               charBuf.clear();
          }catch(IOException e){
               selectionKey.cancel();
               System.out.println("Logout:: Server port:" + datagramChannel.socket().getLocalPort() +
                                        ". Client: " + datagramChannel.socket().getInetAddress() + " / " +
                                        datagramChannel.socket().getPort());
     }

Hi,
Instead of data_output.writeChars("\n");, do data_output.writeChars(System.getProperty("line.separator"));Rgds,
Andre'

Similar Messages

  • Can't open my pdf after scanning file please help!!!

    this scanner is connected to a PC and is shared so we can see all documents, great but here begins the problem:
    1- scan documents
    2-select format type
    3-select PDF
    Everything´s OK until that point, but when i try to see the documents scanned
    This is what comes up when i try to see with adobe reader(no matter the versions):
    ADOBE READER COULD NOT OPEN (name of the file) BECAUSE IT´S EITHER NOT A SUPPORTED FILE TYPE OR BECAUSE THE FILE HAS BEEN DAMAGED (IT WAS SENT AS A E-MAIL ATTACHMENT AND WASN´T CORRECTLY DECODED.
    NOTE 1:
    If i save the file with only 1 page the file opens and i can see the documents but when i try more than one page comes up the error!!! And if try to send it over the net the receptor can not see it due to the same error!!!
    NOTE 2:
    Rarely when i try to open the file with foxy reader it opens!!! without any problems.
    I don´t know what´s the problem please help!!! It could be the way i´m saving the file? I just reinstalled the drivers and nothing!!! same old same
    Please answer!!!
    This is the file:
    https://acrobat.com/#d=poQX7k*KL9fRulu2S8nMPQ

    Please don't start a new topic if you already have a topic open with the same problem.

  • CS5- Can't print single pages in tiled file- please help?!?

    When I go to print a document I no longer have the option to choose a range of pages to print in my tiled files.  The "All" option is selected and the "range" opion will not select.  I'm not doing anything different than what I did with CS3.  Using Creative Suite with Window's 7.
    Please help!
    Thanks

    Sometimes it seems like they have made this very hard when they actually made this easier for you.
    It is right in front of you but because you are not expecting it to be there you don't see it.
    Screen Tile>Tile Range that simple!
    It numbers your tiles for you nicely and doesn't give you odd shape tiles.What do you think of this new feature?

  • Drop down write in- multiple lines

    I have a drop down and in it the user can select one choice or write in their choice. But when the user goes to write in they can only write in one line. Is there some way to change that to the space provided?
    Thanks,
    Kerry

    I'm having a similiar issue here at my project.
    What is the filename of your file you're writing? did you include %SEQ% or a similiar naming convention?

  • How can read/write FORMSWEB.CFG & DEFAULT.ENV file entries programatically?

    Environment: Forms 9i (Web)
    As : Oracle 9i As
    How can read/write FORMSWEB.CFG & DEFAULT.ENV file entries programatically?

    I guess you cannot. There is an enhancement request to get the name of the config-section as a GET_APPLICATION_PROPERTY.
    What you could do is add extra parameter(s) to your form and pass the necessary formsweb.cfg parameters in this form parameter. See Get formsweb.cfg section name in Forms for more info and an example.

  • I'm getting this problem when trying to update my iphone 3gs it says that the iphone software could not be contacted and I went on youtube got some advise to go into my hard drive to fix the error I have nothing in my host file please help me if you can

    I'm getting this problem when trying to update my iphone 3gs it says that the iphone software could not be contacted and I went on youtube got some advise to go into my hard drive to fix the error I have nothing in my host file please help me if you can this is all new to me.

    Read this: iOS 4: Updating your device to iOS 5 or later
    ... oh I think it is a 3gs or a 3
    This makes a difference. What does it say in Settings > General > About?

  • I recently have ipad but before i sell it i made a back up of it and by an iphone when i put all the date on my iphone some files and software did not install is there anything i can do to recover the lost data? please help

    i recently have ipad but before i sell it i made a back up of it and by an iphone when i put all the date on my iphone some files and software did not install is there anything i can do to recover the lost data? please help

    I don't think you're on iOS 5, I think you're using iOS 6.  That's the latest version.
    Unless you've used iCloud to back up your documents, you won't be able to restore them.  And for future reference, you don't have to uninstall Pages to update your iPad anymore.  Sorry about this.

  • HOW TO - Create new from clipboard and process multiple files - please help

    Need help - have new version of photoshop on trial only ATM...
    Want to know - HOW TO:
    1. Create new from clipbaord
    2. Process multiple files
    Please help.

    For clipboard copy, I start with File > New and the size will be set to what's in the clipboard. Then once the new file is opened, Edit > Paste will place the clipboard contents as a layer in the new document.
    You must remember to use the command Layer > Flatten Image of you want to save as jpeg or any other file format that doesn't support layers.
    For processing multiple files,
    File > Automate > Batch or
    File > Scripts > Image Processor...
    Check the User guide or google information for those commands if you have specific needs.
    Gene

  • HT4623 hey,my iphone (5) is in recovery mode so I downloaded ios 7 from the laptop then after the download was completed the laptop was extracting the software and at the end of the loading line it writes an unknown error occurred (3194) please help me th

    he download was completed the laptop was extracting the software and at the end of the loading line it writes an unknown error occurred (3194) please help me thank you

    3194  =  https://discussions.apple.com/message/18851577#18851577

  • Lost unsaved Garage Band File - PLEASE HELP

    Lost unsaved Garage Band File - PLEASE HELP
    I had an audio file made on Garage Band but it was unsaved. I left my computer on at night and for some reason this morning my computer had seemed tor restart. I opened the garage band file but nothing came up.
    Is there any way I can recover this 'unsaved file'? It must be stored in cache somewhere.
    Someone please advise.
    Thanks.

    I would just like to say Thanks to HangTime up there. This trick worked 100% ... I had recorded 8 or 9 rather long tracks; for an unexpected reason (first time I've ever seen the "gray screen of death") the popup window came up and in several languages told me I needed to restart the computer; did what it told me to, begrudingly. Came back online, opened the GB file, nothing was there. Yet, when I checked package contents for the file (which I didn't even know existed, compartmentalized "Media", until after reading this), there were the tracks! I owe you both for getting this up and running... album creds just may be in line. ~Matt

  • Counting lines problem. Please help!!

    Hi all,
    I just have a small problem i cannot resolve, here it is: I read through a file and i like to count the lines of the file there is before a special word.
    E.g
    My file contains:
    "hi
    how are you
    my name is john
    and i live
    britain"
    I'd like to count how much lines there are in the file before the word LIVE ==> result would be 4.
    I proceed with StreamTokenizer, but i don't knor how to specify the word. Here is my code:
         try {FileReader fr = new FileReader("test2.dat");
                   BufferedReader br = new BufferedReader(fr);
                   StreamTokenizer stk = new StreamTokenizer(br);
                   do {
                   n = stk.nextToken();
                   li = stk.lineno();
                   if (n == stk.TT_NUMBER) {
                        n = stk.nextToken();
                   if (n == stk.TT_EOL) {
                        li++;
                        n = stk.nextToken();
                   if (n == stk.TT_WORD) {
                        String str = stk.sval;
                        if ("entier".equals(str)) {
                             System.out.println(li);
                        else {
                             n = stk.nextToken();
                   while (??????????????);
    I want here to specify the word "entier" but how to do this??
    Thanks very much for your precious help....

A: Counting lines problem. Please help!!

Use LineNumberReader, which counts lines for you. Here's a complete program in 16 lines:
import java.io.*;
public class test4 {
  public static void main(String[] argv) {
    if (argv.length < 2) { System.err.println("no arg"); System.exit(0); }
    try {
      LineNumberReader in = new LineNumberReader(new FileReader(argv[1]));
      String line;
      while((line = in.readLine()) != null)
        if (line.indexOf(argv[0]) != -1)
          System.out.println("Found match at line " + in.getLineNumber());
    } catch (IOException e) {
      e.printStackTrace();
}If you want case insensitivity, you can make both lines lower-case before searching. Or you can use regular expressions.

Use LineNumberReader, which counts lines for you. Here's a complete program in 16 lines:
import java.io.*;
public class test4 {
  public static void main(String[] argv) {
    if (argv.length < 2) { System.err.println("no arg"); System.exit(0); }
    try {
      LineNumberReader in = new LineNumberReader(new FileReader(argv[1]));
      String line;
      while((line = in.readLine()) != null)
        if (line.indexOf(argv[0]) != -1)
          System.out.println("Found match at line " + in.getLineNumber());
    } catch (IOException e) {
      e.printStackTrace();
}If you want case insensitivity, you can make both lines lower-case before searching. Or you can use regular expressions.

  • I have a Macbook Pro purchased brand new. I take high quality pictures for customers, these display perfect on my laptop but appear CORRUPT on a USB stick. What is causing this? I can't seem to fix this issue. PLEASE HELP!!

    I have a Macbook Pro purchased brand new. I take high quality pictures for customers, these display perfect on my laptop but appear CORRUPT on a USB stick. What is causing this? I can't seem to fix this issue. PLEASE HELP!!
    I really need this issue resolved it is driving me insane!!! How can the images appear perfectly fine on my laptop then when transferring over to a USB stick they just  corrupt!?

    Check out this site:
    http://osxdaily.com/2012/04/22/format-drive-mac-pc-compatible/
    That will show you how to format a USB stick for use on both PC and Mac.
    If the problem continues take it to an Apple store and have them check it out.
    >Also what s exFAT?<
    From:
    http://en.wikipedia.org/wiki/ExFAT
    "exFAT (Extended File Allocation Table) is a Microsoft file system optimized for flash drives.[3] It is proprietary and patented."
    That first site explains it at length.

  • Illustrator CS4 wont save files, please help?

    You can edit a file, go to save, close it down, then when you re-open it the changes made have not been saved?? No error message or warning pops up, and it all looks ok like it has saved properly, until you open it up again. This also happens when you use 'save as' command if you use the original file name. If however you type in a different file name - it saves ok. But obviously that is not great as you cant now trust or rely on the save mechanism of the programme, to make sure any changes to artwork have been stored!! I have never seen an issue like this, it is worrying, I hope somebody can help?
    Thanks.
    We are running CS4 on windows7 - yes PC!!!

    We save in EPS, and its not just one file, its a variety of different files and it seems to be random as to which files it does it on, some work fine - some don't. And it can be anything from a minor text change to a colour change, it doesnt seem to matter on the change made, it reacts the same.
    The files are saved over a network connection to a large external hard drive.
    Its really puzzling and now starting to cause problems as we do a fair bit of work in it, and can't trust one of the most important features, and that any changes that have been done have been saved and stored!
    Hope maybe you can help with any thoughts at all.
    Cheers.
    Date: Thu, 24 Jun 2010 03:41:40 -0600
    From: [email protected]
    To: [email protected]
    Subject: Illustrator CS4 wont save files, please help?
    What file format do you save it in?
    What kinds of changes did you make in that file?
    Where do you save the file (removable or network media)?
    >

  • How to view corrupted word files, please help?

    Can't view doc corrupted file .How to recover unsaved documents WORD? how to view corrupted word files, please help

    It could be Word or even Windows that is having the problem. Before you start trying to restore a backup or repair a file, try opening other documents.
    Try opening your "corrupt" document from another computer. Also you can try to make a copy of corrupted files. (It could work) : http://www.filerepairforum.com/forum/microsoft/microsoft-aa/word/968-i-would-be-grateful-for-any-help-to-repair-or-the-procedures-word-files
    But if nothing helps, you can try to recover it by using DOCX Viewer Tool Download free demo versions of this software from website: http://www.docx.viewertool.com/ It’s
    gonna help.

  • Dear Apple Support ,  This is FAHAD ALGORWAN ,I can't remember my security question answers , so Please help me to Create new Security Qu

    Dear Apple Support ,  This is FAHAD ALGORWAN ,I can't remember my security
    > question answers , so Please help me to Create new Security Qu

    Please do not make multiple posts. One is enough. These are user forums, so you are not speaking to Apple here.
    The Best Alternatives for Security Questions and Rescue Mail
        a. Send Apple an email request at: Apple - Support - iTunes Store - Contact Us.
        b. Call Apple Support in your country: Customer Service: Contact Apple support.
        c. Rescue email address and how to reset Apple ID security questions.

  • Maybe you are looking for