Sending file to server UTF-8 text

I am trying to download a UTF-8 text file to a server. The download works fine, but when I check in the server, the file is ASCII.

This is how I create my file:

private void writeToFile(String line) throws IOException{
        FileConnection fc = null;
        try {

            FileConnection fileConnection = (FileConnection)Connector.open(Constants.FOLDER_FILES+fileName);
            if (!fileConnection.exists()){
                fileConnection.create();
            }
            fileConnection.close();

            fc = (FileConnection)Connector.open(Constants.FOLDER_FILES+fileName, Connector.READ_WRITE);
            long byteOffset = fc.usedSize();
            OutputStream outStream = fc.openOutputStream(byteOffset);
            outStream.write(line.getBytes("UTF-8"));
            outStream.flush();
            outStream.close();

        }catch (IOException ioe){
            UtilsFiles utilsFiles = new UtilsFiles();
            utilsFiles.writeInLog("UtilsFiles error: writeToFile ioexception "+ioe.getMessage());
        } finally {
            if (fc!=null) {
                try {
                    fc.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

And in the way which I download it:

public class HTTPUploader {

    private String _connectionURL = null;
    private String fileName;
    public HttpConnection httpConnection = null;

    public HTTPUploader(String _fileName) {
        fileName = _fileName;
    }

        public void run (){

        httpConnection = null;
        _connectionURL = null;
        String lineEnd = "\r\n";
        String twoHyphens = "--";
        String boundary = "*****";
        int rc = -1;
        OutputStream os = null;

        try {
            httpConnection = (HttpConnection)Connector.open(_connectionURL);            

            httpConnection.setRequestMethod("POST");
            httpConnection.setRequestProperty("Connection", "Keep-Alive");
            httpConnection.setRequestProperty("User-Agent", "BlackBerry");
            httpConnection.setRequestProperty("Content-Type", "multipart/form-data;boundary=*****");
            httpConnection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_LANGUAGE, "en-US");
            httpConnection.setRequestProperty(HttpProtocolConstants.HEADER_CACHE_CONTROL,"no-cache, no-store, no-transform");           

            os = httpConnection.openOutputStream();
            os.write((twoHyphens + boundary + lineEnd).getBytes());
            os.write(("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + fileName +"\"" + lineEnd).getBytes());
            os.write(lineEnd.getBytes());
            byte [] postDataBytes = getData();
            os.write(postDataBytes);
            os.write(lineEnd.getBytes());
            os.write((twoHyphens + boundary + twoHyphens + lineEnd).getBytes());
            os.flush(); 

            rc = httpConnection.getResponseCode();
            InputStream in = httpConnection.openInputStream();
            ...
        }
        catch (ClassCastException cce)
        {
            ...
        }
        catch (IOException ioe)
        {
            ...
        }
        finally
        {
            ...
        }
       }

       private byte[] getData() throws IOException
       {
                FileConnection fileForUpload = (FileConnection)     Connector.open(Constants.FOLDER_FILES+this.fileName, Connector.READ);
        InputStream is = fileForUpload.openInputStream();
        return IOUtilities.streamToBytes(is);
       }

...

}

I get the file correctly, but it is ASCII, and I don't know why.

Thanks for your help

Makes you think the ASCII file?

Remember that MARC and UTF-8 are not actually different assuming that you only ASCII characters in the file.

Tags: BlackBerry Developers

Similar Questions

  • Messages can not send files

    I tried power off to solve a problem with the Messages/iChat for 6 months now and I hope the Apple community might have a solution. We have an office with a mixture of Mac under OS X (based on capabilities) 10.6.8 (off 10), 10.10.5 (2 for those who hate the model) and 10.11.4 (2). We use Hello messages to send text messages, video chat and send small files (usually images) internally around the office. About 6 months ago Messages/iChat lost the ability to send files. Everything works fine (except General bugs of windows mobile / endangered and buddies on the machines of Yosemite/model). On the senders end you get no notification that the transfer has failed, or that you get a small 'I' icon in the window of conversations that draw attention to the failure. The same thing in the 'File transfer' window, sometimes the file will be marked as 'sent', or 'fail', in both cases, the receiver sees the transfer as it is 'impossible' or it crashes with a progress bar that changes to 'fail' if interact you with the download arrow or double-click on the file icon.

    Various forums to suggest solutions, that everything I tried:

    • Quit and restart Messages.
    • Restart the computer.
    • Deleting of plist.
    • Make sure UPnP is enabled on the router.
    • Make sure UPnP is not enabled on the router (learned to love these weird problems, everyone has a different idea)!
    • Ensure ports 443 (Messages), 5190 (UDP for Messages), 5297, 5298 (UDP Hello) and 5298 (TCP Hello) are all open.
    • Compress images.
    • Force quit "matches" in the activity monitor.
    • Ensuring that no one is Little Snitch active.
    • Ensuring that there is no firewall on.
    • Ensuring that user names are not too long (there was a suggestion Hello has an internal deadline that could result in names are identical coupe).
    • Make sure that OS X is updated (this persisted for several updates now).

    There is a guy named Ralph Johns (UK) on Apple's Support forums, which has been troubleshooting this kind of problem with iChat/Messages with various posters since at least 2011. Seems to know his stuff, but has not been able to find a solution for everyone. Posters have tried swapping routers, used wireless instead of ethernet (or vice versa) and even two bad guidance computers connected together via a simple switch, so I am not convinced that there is a network problem.

    Anyone have any ideas?

    Hello

    I've done it since 2004 in fact.

    Re: -.

    • Ensure ports 443 (Messages), 5190 (UDP for Messages), 5297, 5298 (UDP Hello) and 5298 (TCP Hello) are all open.

    IMessages Login using port 443 (made the AIM Login today and Yahoo if you have configured the account)

    Swaps the GOAL to use port 5190 (UDP when this file transfers).

    The other three ports lists are listed as being necessary by Hello but use Little Snitch myself I was never able to prove that a similar thing on behalf of the GOAL and Exchange port during the basic move IM chat to those containing photos of cats.

    Re: -.

    Ensuring that no one is Little Snitch active.

    Little Snitch will block (if you tell) the processes that you cannot associate with Messages as such.

    It's pop up you should see if you transfer files with the iMessages account. (Note the server and port).

    Why they have put in place a different process instead of use the same AIM, Jabber and Hello use.  It has a slightly different name.

    I tried to send pictures on PURPOSE to my MacBook Pro that uses iChat 5.0.3

    I have also tried to send using Hello from iMac MacBook Pro and cannot operate.

    However the Hello from the MacBook Pro to the iMac strangely works.

    The version of iChat says that the File Transfer window expected FRO me (in the iMac) to meet start sending in trying to use AIM.

    However, the Chat window in iChat 5.x.x watch separately a message from AIM servers saying that the AIM Proxy did not work and try again and it make no changes to the file transfer window.

    2nd attempt to use iChat 5.x.x Hello also failed.

    It seems to be no reason why it fails.

    Re: -.

    Ensuring that user names are not too long (there was a suggestion Hello has an internal deadline that could result in names are identical coupe).

    Hello items in the sidebar of finders tend to take the name of system preferences > sharing

    The ID Hello buddy would then map My user on the name of the computer remote computer@the

    Possibly the naming conventions have changed over time, but I don't normally have questions (the MacBook Pro doesn't seem like spaces or apostrophes when I named it wherever the iMac running OS version much later when appointed allows them).

    However as I had them connected should not be the issue.

    Which can be a problem is to name them all Macintosh or the Admin according to the naming process, that you can use and if a Diskimage is used to make them all have the same applications and settings.

    UPnP occurred as iChat 3 and 4 used so several ports you couldn't open them all in Port Forwarding set ups.

    Video and Audio conversations only used 22 ports

    GOAL was three

    Hello supposed to use 3 in the Apple Documentation

    Jabber claimed to need at least one, but was actually 2 to cover the SSL connections.

    See using iChat with a firewall or a NAT - Apple Support router

    Two things that you don't mention that you have tried.

    NVRAM (PRAM) reset How to reset NVRAM on your Mac - Apple Support

    and a secure start

    Repair permissions appeared in disk utility in El Capitan and was always decried as useful in many settings, while others swore by it.

    Finally, you might want to watch and read and write permissions.

    It has become much more complicated with some applications such as Messages can be sandbox which adds several layers of reading and writing of files you need also to have access to write even the .plists

    I'd take a peek at this thread and useful (Orange) marked post-test and resolved green one if necessary.

    The Original message is followed by the fixed one but one useful by that you should start is then displayed.

    21:42 Thursday; July 21, 2016

     iMac 2.5 Ghz i5 2011 (El Capitan)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro (Snow Leopard 10.6.8) 2 GB
     Mac OS X (10.6.8).
     iPhone and iPad (2)

  • Only 30 seconds to send files to computer because I activate bluetooth

    Can I send files to my computer, but just as soon as I turn on my bluetooth stack. I have the latest version of Toshiba and a Tecra 9100. If I turn on my bluetooth stack I must be quick at sending the files on my computer to my mobile. Within 30secs (approx) each, I can send as many files as I want.

    But after 30secs it's too late - my mobile says it cannot associate unit. I must therefore keep go Bluetooth, Wi - Fi on my computer if I want to send a file on my computer and my bluetooth stack has been activated for more than 30secs.

    It's quite embarrassing. Any help will be appreciated.

    You can send files via bluetooth as long as it is switched on and active service. The only problem, you should see is a time out if you do not confirm the request on the receiver side within 30 seconds. This timeout is controlled by the Bluetooth chip.

    So this time cannot be changed by software. The only solution for your problem would be to disable confirm the receive window. Then you can do this with the following:

    Start "Bluetooth settings"-> Bluetooth-> Options...-> security-> custom level...
    -> Bluetooth information interchange: check "display a confirmation message upon receipt through Push (OPP) of the object.
    -> Object Push (OPP) security setting: check "perform authentication and encryption (server).
    The last parameter is optional, but recommended as it requires once to enter an access key (e.g. 3248) laptop and mobile phone.

    Not required for other assignments. This forbidden that any unknown person cannot send files without your awareness (as you know a confirmation window will appear no more) to your laptop.

  • Read/write file in Unicode (UTF-16)

    Hi, I have a problem to write a file in Unicode (UTF-16)

    I have to read a file with LabView, change some settings and write the new data in the same file. The file uses Unicode UTF-16.

    I downloaded a few library here: https://decibel.ni.com/content/docs/DOC-10153

    I can read the file, convert the data to ASCII/UNI/UNI and then write the file. But when I open the new file with an editor like Notepad ++ there is some unexpected characters at the end of the line.

    Even read the file and write exactly the same doesn' data not work.

    I've attached an example.

    Thanks for you the kind of support.

    Right click on your functions read and write text files.  There is an option to "Convert End Of Line".  Who turned off the two functions.

    As a side not, you need not close file functions.  The functions Read and Write Text File will close the file that reference output file is not connected.

  • Conversion of Outlook Express .dbx to Microsoft Live Mail issue box for receiving and sending files conversion

    I am able to convert most of my old Outlook Express files to Microsoft Live Mail, with the exception of the Inbox, and send files.   The two files are not empty.  My OS is Windows 7 64 bit.  The 'Files' file is located in the directory with the .dbx files.  Most of the files have been converted except these two.  The converted file sent.

    Can advise you on what to do to fix this?  I need the information contained in the Inbox, and send.   I have more access to Outlook Express.

    Best regards, Kat

    Unless you left no messages in the Outbox, it must be empty. Messages are just going through there on the way to your mail server.
     
     
    Folders.dbx is the "brain" of the system of dbx files and contains all the actual messages.
     
     
    Now regarding the messages from the Inbox, I don't know why they won't matter in Windows Live Mail. You compact the folders in OE before saving the message store? WLMail has great trouble with import of dbx files. How do you backup and transfer the storage of OE with dbx files folder?
     
     
    If you still have access to the machine with OE, it would be easy to fix. Given that you don't do it, you probably have two options.
     
     
    If you have professional, enterprise or ultimate edition, you can use OE in XP Mode. Who can import all the messages and then we can transfer it to WLMail.
     
     
    How to use Outlook Express in Windows 7
    http://www.oehelp.com/OEnWin7.aspx
     
    If you cannot use the XP Mode, and can not find an OE to 'borrow' to a friend, you will need a recovery tool. Unfortunately, it is not free.
     
     
     
     
  • flashvars sends to the server

    I have a SWF with flashvars from the server loads. Now the customer must answer a question and his or her response will change the flashvars which will be send to the server again.
    I want to use URLRequest and URLVariables (which contains the user's new response; the flashvars changed). My problem is that I do not know the url, the only thing I know is that it is the active url (where the SWF has received the flashvars parameters). I have to replace "url active" in the following line:
    var newFlashvars:URLRequest = new URLRequest ( url active);

    Thanks in advance.

    Kind regards

    Harry

    AS3 your file, you can get the SWF file location by using the following code

    trace (this.) LoaderInfo.URL)

    Hope this will help you

  • Where can I find that firefox sends to the server?

    If I go over a left link under I see what request is sent to the server.
    What happens when I see: javascript: {_JSL (PAGE_, ' A43 ","_self", )}
    What is a script that is executed on the client side or server side?
    In general, how to find out what request is send to the server.
    Thank you

    Hi, maybe the web developer tools firefox will come handy: https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor

  • Cannot send files from the phone to Satellite L755-16z using BT

    Hi, experts :)

    I'll get straight to the point!
    I have a toshiba satallite L755-16z for a month or two (New, with windows 7 64-bit)
    and knows that it has BT and I guess that its 3.0

    So I tried to connect the bluetooth with my phone & it paired very well!
    but when I try to send files and from my phone, it says (connection) but fails to send it in the end. In addition, this problem is not just with my phone as I tried issuing and receiving to & from another phone, but always the same problem!

    HOWEVER, I tried to turn the BT adapter off (right-click on the icon in the notification area and then turn off bluetooth adapter), start the application (bluetooth monitor) can send files & IT WORKS!
    But this only happens for once just after the restart of bluetooth, so every time I want to send files, I have to turn off BT, then turn it on?
    It is kind of unacceptable!

    I tried Toshiba Bluetooth Stack, and he had the same problem. In addition, I didn't like the way it worked (style and all)... so I uninstalled & returned to the original version of BT in the pc.

    I looked for answers to no luck & now I'm desperate for the answer!
    Please anyone knows how to fix it, help me please? !
    If my email is required: [[email protected]]

    > HOWEVER, I tried to turn the BT adapter off (right-click on the icon in the notification area and then turn off bluetooth adapter), start the application (bluetooth monitor) can send files & IT WORKS! But this only happens for once just after the restart of bluetooth, so every time I want to send files, I have to turn off BT, then turn it on?

    Usually the BT must be activated using the Fn + F8 key combination.
    So remember that BT has been enabled using these buttons.

  • C50 - B - 14 d - Bluetooth satellite will not receive but send files

    I got my laptop about a month and now needs to work bluetooth
    I have a C50 Satellite - B - 14 d

    Bluetooth is not receiving but sends end

    help please someone.

    Martin

    I would suggest temporary disable the antivirus and firewall, then check the result.
    If the problem persists, check if this problem occurs during the transfer of data with the help of different devices.

    Another proposal:
    Search for "fsquirt" to the start screen.
    The fsquirt is a Bluetooth File Transfer Wizard that allows users to transfer files between a computer and a device with Bluetooth.

    Launch "fsquirt" and then if you want to send a file, choose "send files".
    If you want to receive files, select "receiving files."

  • 6.22.59.107 - where of the button: 'Screen Share' & "send files"?

    After upgrading to a new one version (6.22.59.107) - could not find two of my beautiful button:

    -"Share the screen.

    -Send files.

    In an earlier version, if I open a contact - in a single window: there is a button '+' - where can I choose send files or share my view of the screen.

    But now - I see here only 3 of the icon:

    -' video call '.

    -' call '.

    'Add people. '

    That is what it is?

    Why so much?

    The "missing" buttons are here. Screen sharing option is not available in the event of actual call.

  • Need information on sending files

    Hello ,.

    I have a question I am very curious, and I hope that someone could help me. So, about 4 months ago I sent a large number of files to a single person via Skype and he did not accept all of them (or denied), I guess that it just has not seen, we had some problems with Skype that day. And now, after a long period of time, I hear the sound of Skype to a file being refused to send and "orange" around his avatar, like the one you see when you receive a new message (but it wasn't). Now to my question: is it a kind of period that Skype has files not being not to send, and lets say, maybe after that time, it automatically it declines for the user, or is it absolutelly who finally refused it? This question may seem silly, but it's really important for me right now and I need to know.

    Thanks in advance

    Both worse, needs more help. Just found that Skype latest version automatically accepts and sends files if they are still available.

  • Impossible to use IM or call or send files or calls to quit smoking or anything like that

    Hello.

    Unfortunately, since yesterday, I'm completely unable to do anything on Skype. I can't call, I can't IM, I can't send files, videos, contacts, etc and when I try to call, I can't quit never call. So I'm permanently stuck in a call now. I can't do everything in groups or just for a contact, etc. Skype is 100% broken for me and I can't do a thing in it. I can receive messages, but what is an instant messaging program if you can't send messages... Please fix this major issue soon because I do not want to be able to use Skype, however, it is I can't do anything about the program because it won't let me.

    Bye and have a nice day.

    If anyone happens to read this solution, it is almost the solution given by a representative of Microsoft technical support, however, "then go to Windows start and in the search/run box, type %temp%\skype and then press enter or click the OK button. Delete the DbTemp folder. "is an unnecessary step and can be avoided. Thank you for your help to solve this problem.
    (Also, as you can see, even a very old, slow computer is able to run Skype and many other intensive programs (Java and Eclipse) simultaneously on Windows 10.

  • Re: Sending file failed

    Hello

    I am trying to hook my LG to my N97 netbook. Nothing spectacular to send files. I have the Bluetooth Stack (T) v.6.40.02 with windows XP.

    I did (right-click on the system tray icon Bluetooth-> Options-> Security-> Custom Level-> Mode: level of link applied security) which provided a way to transfer file from my N97 to my netbook, but not a file from my netbook to my N97. It says: failed to send file.

    Is there a size limit?

    Thanks in advance.

    You connect the phone using the PC Suite mode or mass storage mode?

    I use the USB cable to transfer files to and from my N97, there is no file limit. I have not tried many bluetooth...

    The USB cable works ok?

  • undocumented function "utf-8 text.


    More than two years. Now, I found the equivalent named "UTF-8 text" (using the VI script).

    If someone else wants to convert text to and from UTF8, the two functions are in annex VI (recorded for LabVIEW 8.0).

    Greetings,

    SHB

  • Sending files to T450s Android phone via bluetooth

    Hello!

    I have associated my Samsung S3 Android phone with my newly bought T450s. I can easily send files to my phone by doing a right click on the file and choose to send it via bluetooth, but whenever I try to send it to my T450s from a phone I just get information which "cannot send the file" and I don't get any notification pop - up of any kind on my laptop.

    How can I solve this problem? I need to install additional software to receive files?

    P.

    Try this?

    http://plugable.com/2013/11/11/easy-way-to-use-Bluetooth-to-Exchange-files-with-your-phone-in-window...

    Comment to Moderator: Marked as the last answer to the OP is a response to this post...

Maybe you are looking for