Working with binary files

I want to save in the MIME Repository an image, I already did it using this code:
DATA: lr_mime_rep TYPE REF TO if_mr_api.
DATA: lv_filename TYPE string.
DATA: lv_path TYPE string.
DATA: lv_fullpath TYPE string.
DATA: lv_content TYPE xstring.
DATA: lv_length TYPE i.
DATA: lv_rc TYPE sy-subrc.
DATA: lt_file TYPE filetable.
DATA: ls_file LIKE LINE OF lt_file.
DATA: lt_data TYPE STANDARD TABLE OF x255.
PARAMETERS: p_path TYPE string
DEFAULT 'SAP/PUBLIC/Test.jpg'. "<<-- Mime path, save to path
cl_gui_frontend_services=>file_open_dialog(
CHANGING
file_table = lt_file " Table Holding Selected Files
rc = lv_rc ). " Return Code, Number of Files or -1 If Error Occurred
READ TABLE lt_file INTO ls_file INDEX 1.
IF sy-subrc = 0.
lv_filename = ls_file-filename.
ENDIF.
cl_gui_frontend_services=>gui_upload(
EXPORTING
filename = lv_filename " Name of file
filetype = 'BIN'
IMPORTING
filelength = lv_length " File length
CHANGING
data_tab = lt_data " Transfer table for file contents
EXCEPTIONS
OTHERS = 19 ).
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_length
* first_line = 0
* last_line = 0
IMPORTING
buffer = lv_content
TABLES
binary_tab = lt_data
EXCEPTIONS
failed = 1
OTHERS = 2.
lr_mime_rep = cl_mime_repository_api=>if_mr_api~get_api( ).
lr_mime_rep->put(
EXPORTING
i_url = p_path
i_content = lv_content
EXCEPTIONS
parameter_missing = 1
error_occured = 2
cancelled = 3
permission_failure = 4
data_inconsistency = 5
new_loio_already_exists = 6
is_folder = 7
OTHERS = 8 ).
But I want to directly fill the  lt_data with a string that holds the binary code of the image, I mean
I don't have the image, only the binary code, I try to do it uploading the .bin file also in .txt format, and
I don't get it :S ,   how can I achieve this?
Thanks in advance!

I´m not sure if Im understanding what you´re saying... If you dont describe the path, then the file will be created in the project folder, right?
check this program out
it doesnt specifies a path but if you try run it the file will be created in the project folder. ¨
import java.io.*;
import java.util.*;
/**  Write a primitive type data array to a binary file.**/
public class BinOutputFileApp
  public static void main (String arg[]) {
    Random ran = new Random ();
    // Create an integer array and a double array.
    int    [] i_data = new int[15];
    double [] d_data = new double[15];
    // and fill them
    for  (int i=0; i < i_data.length; i++) {
      i_data[i] = i;
      d_data[i] = ran.nextDouble () * 10.0;
    File file = null;
    // Get the output file name from the argument line.
    if (arg.length > 0) file = new File (arg[0]);
    // or use a default file name
    if (file == null) {
        System.out.println ("Default: numerical.dat");
        file = new File ("numerical.dat");
    // Now write the data array to the file.
    try {
      // Create an output stream to the file.
      FileOutputStream file_output = new FileOutputStream (file);
      // Wrap the FileOutputStream with a DataOutputStream
      DataOutputStream data_out = new DataOutputStream (file_output);
      // Write the data to the file in an integer/double pair
      for (int i=0; i < i_data.length; i++) {
          data_out.writeInt (i_data);
data_out.writeDouble (d_data[i]);
// Close file when finished with it..
file_output.close ();
catch (IOException e) {
System.out.println ("IO exception = " + e );
} // main
} // class BinOutputFileApp

Similar Messages

  • Problem working with binary file

    Hi,
    I have two seperate programs.
    The first one:
    *Reads a  PDF file from disk via InputStreamReader.read(char[])
    *converts it to s String [String.valueOf(char[])]
    connects to other program using Socket and writes the string's bytes to the OutputStream of the Socket (socket.getOutputStream().write(string.getBytes);)
    Second one:
    *Reads the file from socket via BufferedReader.read(char[])
    *converts it to a string via String.valueOf()
    *writes it to a file using FileOutputStream.write(content.getBytes())
    The problem is:
    If the secong program is running on Win2K,the PDF file is opened with no errors but the pages are all blank.But everything is OK if it is running on Unix(IBM AIX java ver 1.3.1)
    First program is always on Win2K.
    I compared the win2k and unix PDF files,some nonprintable chars are displayed as ? in the win2K one,
    what can be the reason? why does the same problem not occur on Unix?
    Some problems are mentioned on web/forums but these are related with browsers or servlets which I am not using in this case.
    Thanks in advance,

    PDF is a binary file.
    You're doing 1 of 2 possible things wrong....
    1) trying to read a binary file as a text file ( string )
    You can't "just read" a binary file as a text file to extra the strings.
    You need to get the binary format, and parse it's format properly to extract the
    string data.
    2) trying to send a binary file across a socket as a string
    You need to read the PDF file as an array of bytes and send them across
    the socket as such. Trying to convert binary data to characters / strings
    is wrong. characters get converted to and from native encoding schemes to
    unicode.... among other problems.
    regards,
    Owen

  • Has anyone not working with .dv files had synchronization problems?

    Has anyone not working with .dv files had sound synchronization problems? I'm not exactly sure what the alternatives to DV are, but I think one of them is HD.
    The reason for asking this question is to help isolate the nature and cause of a very serious flaw in iMovie '11. In the original release of iMovie '11 (version 9.0) there was a small--but serious--synchronization problem. In the 9.01 there is a large synchronization problem. We know of one person who has not experienced the problem, and he is not working with DV files (media). So we want to find out if anyone who is using something other than .dv files is experiencing a lack of synchronization between sound and picture. Knowing the answer to this will help with figuring out where the cause lies. For the initial iMovie '11 release (9.0), you probably would not notice a problem unless you had very long event-clips, e.g., two hours long. Events get this long if you are transferring from analog 8 mm tapes. Even then, it would have to be in scenes in which the connection between event and sound is obvious, e.g., close ups of people talking. It isn't until the 9.01 release that most people would notice anything. All we need to do is establish one case of a synchronization problem in which the person is using something other than DV.
    Message was edited by: Paul Bullen

    Hopefully, the 9.0.2 release will make my question moot. Zyfert must have posted the announcement of the release just as I was formulating my question. Still, if you have information on the subject, it would be interesting to hear.

  • Working with RAW files in PSE9:  Doable or better to use PSE12?

    I have PSE 9 and will soon get a camera with RAW capability.  I notice that Adobe no longer supports PSE 9.  Am I in for trouble if I don't upgrade to PSE 12 since I don't know how to work with RAW files?  It sounds as if I will need something to convert RAW files?  Where do I get it?  Is it a big deal for a beginner with no software skills?

    You can download a free DNG Converter from Adobe and then convert your RAWs to DNGs which can be used in PSE9.
    You don't need PSE12, but if you want to purchase PSE 12, you get the most current features in the Raw processor (which in my opinion is a huge improvement over what is available in PSE9), and you don't need the extra step of converting to DNG.

  • Very slow responce when working with Office file on DFS-Share

    Very slow responce when working with Office file on DFS-Share
    We have implemented the following configuration
    Domain level Windows 2000. Two member servers with Windows Server 2008 R2, sharing the same DFS namespace with, at the moment, one folder target called Home.
    Users complaining that the access to different MS Office files is very slow. Even creating a new MS Word document using right click context menu takes up to 4 minutes to open. Saving, for example, one singe Excel sheet takes also few minutes.
    Tested with both, MS Office 2007 and MS Office 2010. Makes no difference. When using Office 2010 you can see the message like contacting:
    \\DomainName\Root\Home\UserName. Other files like TXT, JPG or PDF are not affected.
     What makes the thing really weird is the fact, that the behavior described above can absolutely change after client machine being rebooted, suddenly everything becomes very fast and this condition can revert back again just after the next
    reboot.
    Considerations until now:
    1. This has nothing to do with the file size. Even tiny files are affected.
    2. AD Sites are configured correctly and the client workstations see themselves in the correct sites.
    3. This is not an Office issue. If I map my folder target not as DFS, but directly as shared network drive
    \\ServerName\Root\Home\UserName , everything functions as expected
    What makes me suspicious: when using f.e. TCPView to monitor connections, I can see, that each time I make any operation on an office file, there will be a connection established to one of the domain controllers, sometimes to remote ones,
    located in other countries. But on the other side, even if the connection is established to the nearest DC, operations are still very very slow!
    Just forget to say. All clients are Windows 7
    Thanks to all who respond.

    Dear all,
    sorry for the delayed reply. The problem has been solved now and since September 19<sup>th</sup>. everything is functioning as expected.
    What was done:
    Deleted replication targets excepting the initial ones
    Carefully recreated folder targets
    Deleted and recreated  replication groups
    Disabled SNP features on both namespace servers
    Created EnableTCPA registry entry
    Checked that the following Updates are installed
    http://support.microsoft.com/kb/2688074
    http://support.microsoft.com/kb/2647452
    Concering Office File validation KB2553065 - This Update was already declined on our WSUS server
    Kind Regards
    Eduard

  • Working with RAW files in iPhoto 5.0.4 and Elements 4.0.1

    I take photos in RAW mode and download them to iPhoto. When I try to edit the photo in iPhoto, the picture is a tiny little file that is impossible to enlarge with any sort of clarity. Also, the word "RAW" does not appear anywhere on the iPhoto window like I read it is supposed to.
    When I drag the file to Photoshop Elements, I get an editing window that has none of the tools usually associated with JPEG files. I get a separate window in which I can darken or lighten the image, that's it.
    Clearly, I'm doing something wrong. No one in their right mind would ever use RAW if this is how it works.
    Any ideas?

    Hi Jack!
    If you're new working with RAW files, your right, it just doesn't make sense. RAW <imho> is a bit overrated. One thing you will need to keep in mind when shooting in RAW, is you will still need to take a well exposed image. What RAW files will allow are CHANGES in all areas of the image v. JPEG which may allow you to ADJUST a few settings in the image. My only suggestion would be to kepp playing around with PSE until you get the hang of it, it is an excellent image editing software. But realize, a well exposed JPEG and RAW file are hard to tell apart...
    Personally, I do not directly download RAW files through iPhoto but will create a folder and download to here, and simply drage folder to iPhoto to import (which are then 'converted' into JPEG files). This way I have the original RAW images safely located outside of iPhoto as well as in iPhoto. You should set Elements as your choice of application to edit files inside iPhoto.
    Good luck, Rick
    Good link: http://www.elementsvillage.com/forums/ and just for fun: http://www.photoshopcosmetics.com/index.php

  • Working with Large files in Photoshop 10

    I am taking pictures with a 4X5 large format film camera and scanning them at 3,000 DPI, which is creating extremely large files. My goal is to take them into Photoshop Elements 10 to cleanup, edit, merge photos together and so on. The cleanup tools don't seem to work that well on large files. My end result is to be able to send these pictures out to be printed at large sizes up to 40X60. How can I work in this environment and get the best print results?

    You will need to work with 8bit files to get the benefit of all the editing tools in Elements.
    I would suggest resizing at resolution of 300ppi although you can use much lower resolutions for really large prints that will be viewed from a distance e.g. hung on a gallery wall.
    That should give you an image size of 12,000 x 18,000 pixels if the original aspect ratio is 2:3
    Use the top menu:
    Image >> Resize >> Image Size

  • Unexpected problem: uncaught exception when working with audio files in Soundtrack Pro

    Hey,
    Whenever I double click an audio file in the timeline to work on it, I end up getting the Error message: "Unexpected problem: uncaught exception" and Soundtrack Pro eventually crashes.  Also, this happens when I try to work with audio files in the file editor.  I have Leopard and am using Logic Studio 8.  Any insight would be much appreciated. Thanks
    Matt

    Didnt know how to remove the original clip from the STP arrange window - or whatever it's called in STPro.  So I could go no further in my perverse science experiment. 
    It also appeared that I could only import an aif but not a wav? 
    I gave up on STPro and did what I needed to do in Logic, which I use regularly.    
    Thank you for folowing up on this. 
    PS.  I used to use an old PowerPC version (1.0.3) of STPro and loved the way it visually showed the change in the waveform when you added each efffect.  It appears that the new version (3.0.1) does not allow you to do this anymore?  You can render or flatten the effects to see the final waveform, but then you are dead in the water and cant make changes?  
    Im such a newbie at STPro that I am probably not using it right? 

  • Working with Multiple Files in Workspace Layout

    If I was working with multiple files in the workspace layout, they each used to be available for selection from a tab.  Now I can either cascade the files horizontally or vertically - but not have them appear in a tab across the top of the workspace layout.
    Does anyone know how to set the workspace to present multiple files in tabs?  I have CS3.

    Tanya,
    This may not help, but the times when that happens to me is when I go too fast and some operations haven't finished. I then try to select a file that hasn't completed and the file I select is in the process of having the data updated. The worst is when it is trying to render as I am doing something.
    I hope this helps some.
    Mel

  • Help: Working with .MOV files in FCP and forced to RENDER FOR EVERY EDIT

    I'm working with .MOV files from my digital camera in Final Cut Pro and every time I make a new edit, I have to render it in order to see it in the canvas.
    How do I make it so that I don't have to render every edit in order to see it?
    (I've worked with files straight from a DV camera, and editing went fine. I'm assuming it has to do with the .MOV files)

    DV Cameras are not the same thing as a Digital camera. Digital cameras offer video on a limited basis and it's usually highly compressed in a non-editing format such as MPEG-2 or similar. NLEs are made to work with video cameras, not still cameras which is why you're having trouble.
    That's not to say you can't edit video captured with a digital camera, but you need to know how to prep it for editing. Some digital cameras shoot at odd frame rates and they all use some form of compression that is not typically used in editing. This means that you'll likely need to convert your clips to an editable format first using Compressor.
    Andy

  • How Can I Work With PHTML Files In Dreamweaver ??

    I want to work with PHTML files in Dreamweaver CS3 - How do I
    go about getting this to work?

    The solutions is either of the following:
    Adobe Lightroom - Find moved or missing files and folders
    Copy the photos back into the exact same folder and folder location that they were in before
    I don't know what you actually did "when I pasted it back" ... but the bigger issue is that you shouldn't be working with these files in your operating system, period. Once you import them into Lightroom, you don't manage these files in your operating system.

  • Do I need BootCamp in order to work with Publisher files?

    I need to be able to create and work with Publisher files. From what I've read, the only two options are: 1. buy a PC (UGH) and then purchase Windows and Publisher.
    OR
    2. Purchase BootCamp, Windows and Publisher.
    I was hoping that by some miracle, some software company has addressed this. Like Pages or Word.
    Any recommendations?
    Thanks

    You need MS Publisher which is not available for the Mac, there are no compatible programs as far as I know.
    Do you need BootCamp? if you are planning on installing Windows natively then yes, or you could run it in a VM, but with less performance usually.
    Or buy a cheap PC (with windows) and run it there.

  • Problem when load more swf files work with xml files into my movie

    hi ;
    I have one flash file & more of swf files which work with xml files .
    when I load one swf file into my flash file  and remove it and load anther one on the same movieclip in my flash file it load the old swf file.
    when i load one on movieclip and remove it and load anther swf  on anther movieclip the file doesn`t work  and stoped.
    when test my flash file to load and remove swf files without xml file it work fine but when repleaced the swf files with other work with xml files the problem hapend.
    thanks;

    YOu should trace the names of the files that are being targeted for loading to see if they agree with what you expect.  If you want help with the coding you will need to show the code that is relevant to your problem (not all of it)

  • Working with huge files (4GB-15GB) in iMovie 11

    should i keep my smaller (4GB) mp4 files in storage or use the 15GB mov files already imported into iMovie '11?
    I may want to work with these files again in the future, but is it worth the space to keep it in iMovie so I don't have to reload and optimize such large files?

    Welcome to the Apple Community.
    That's really a question only you can answer depending on whether you need the space in the meantime. If not keep the optimised files. If you want to work not only with the event files again but the project again, you will need to keep the optimised files.

  • Working with video files on compatible external drive with imovie09

    I have run out of room on my MacBook Pro hard drive, so I have moved all of my video files onto a compatible external hard drive. How do I work with these file in imovie09, do I need to import the files back onto the computer or can I work with them from the external hard drive, if so how. Also, is it possible to after completing editing to save just the project on the computer rather than the hard drive or will that cause a "source video" issue.
    Ultimately, I would like to have all of the source video saved on the external hard drive and the projects saved on the computer
    I had no problems working and saving the files when just using the computer, the external hard drive has complicated things for me. Thanks.

    John Pichola wrote:
    I have run out of room on my MacBook Pro hard drive, so I have moved all of my video files onto a compatible external hard drive. How do I work with these file in imovie09, do I need to import the files back onto the computer or can I work with them from the external hard drive, if so how. Also, is it possible to after completing editing to save just the project on the computer rather than the hard drive or will that cause a "source video" issue.
    How did you move all of your video files? The best way in iMovie '09 is to do it in the Event Library. Make sure you're viewing hard drives (click the disk icon at the upper-right corner of the list of events). Then drag the events you want from your internal hard disk to the external one. That way iMovie keeps track of where the source files are located.
    You can do the same with project files in the Project Library, too.
    If you've already moved the files in the Finder, to do it cleanly, I'd recommend moving them back to the iMovie Projects and iMovie Events folders in your Movies folder. Then launch iMovie and move them as explained above.
    Or, make sure the iMovie Projects and iMovie Events folders are at the top level of your external hard drive. When you launch iMovie, it looks in those places for footage and projects, and will make them available.

Maybe you are looking for

  • Exporting to PDF, the letter t is exported incorrectly

    Hello. I have an winforms app developed in .net 3.5. Reports are made in Crystal Reports 2008. I have a problem when exporting a report to PDF. The application have about 10 reports, and all but one works fine. The report looks correct when displayed

  • How to extract a double from a little endian stream?

    I want to support Java 1.3.1, which means that I cannot use class ByteBuffer. I would need ByteBuffer with the methods order and getDouble. I read the socket in little endian format (thus I cannot use the getDouble method of the class DataInputStream

  • Photo keep crashing

    Good evening  everybody, I updated  my mac and started to use photo after migration of my library During the migration they were a little problem because I didn't have enough storage, I just deleted couple of movies and i could finish the migration A

  • How to get dynamic boolean expression's value?

    String str = "((true)&((false)|true))"; how to get the result of boolean from str?

  • SAP Mobile Engine with SAP NetWeaver 7.0 Java Trial Version ?

    Hi, I would like to know if I can use the SAP Mobile Engine on the SAP NetWeaver 7.0 Java Trial Version that you can download form SDN or in other words if I can configure a test system with the SAP NetWeaver 7.0 ABAP SP12 and SAP NetWeaver 7.0 Java