How to pass a command string and  file content in a socket?

socket = new Socket(host.getHostIp(), host.getFilePort());
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("c:/test.xls")));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
bw.write("this is my control command.\n");// *\n use to mark a line*
String cur = null;
while((cur =br.readLine())!=null){
     bw.write(cur);
     bw.newLine();
br.close();
bw.flush();
bw.close();then,read from the socket:
BufferedReader myIn = new BufferedReader(new InputStreamReader(_myProcessSocket.getInputStream()));
String command = myIn.readLine();
// read file
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("d:/test.xls")));
String cur = null;
while ((cur = myIn .readLine()) != null) {
     bw.write(cur);
     bw.newLine();
bw.flush();
bw.close();
myIn .close();I find d:/test.xls cannot read,the file is bad.The code below is the same:
     BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("c:/Ñз¢ÈÎÎñ¸ú×ÙÇåµ¥_V5.1.xls")));
               BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("c:/Ñз¢ÈÎÎñ¸ú×ÙÇåµ¥_V5.2.xls")));
               String cur = null;
               while ((cur = br.readLine()) != null) {
                    bw.write(cur);
                    bw.newLine();
               bw.flush();
               bw.close();
               br.close();

You should only get the OutputStream and InputStream once and wrap this in the data streams
To send data -
DataOutputStream dos = new DataOutputStram(socket.getOutputStream());
dos.writeUTF("´ïµ½ddddd");
dos.writeInt(lengthOfFile);
// Now loop reading the  file bytes a buffer and a time and writing them
// using
dos.write(buffer, 0, bytesRead);To receive data-
DataInputStream dis = new DataInputStream(socket.getInputStream());
String valueSent = dis.readUTF(); // Will return "´ïµ½ddddd"
int lengthofFile = dis.readInt();
// Now loop reading the file bytes to a buffer until you have read all the bytes of the file.

Similar Messages

  • How to pass ascii values in receiver file contentversion

    Hi ,
    How to define a ascii vlaues in file content conversion(eg ASCII13) in file reciver adapter.
    Regards
    Swathi

    hi,
    Special Characters in the FCC:
    In all strings for separators (NameA.fieldSeparator, NameA.beginSeparator, and NameA.endSeparator), you can specify non-printable ASCII characters. These characters can each be inserted individually in the strings in the form ´0xHH´ (including the quotation marks), where HH represents the character coded as a hexadecimal value. A line break can be entered using the character ´nl´ (including the quotation marks); nl stands for new line. The special character ´0´ is not a separator character.
    and
    Specify the File Type of the document.  :  Binary/ Text
    Under File Encoding, specify a code page.
    The default setting is to use the system code page that is specific to the configuration of the installed operating system. The content of the message is then converted to the corresponding code page before the message is saved as a file.
    You should use this conversion only for plain text and not for XML documents. If you want to change the encoding of an XML document, then select the File Type as Binary and apply XMLAnonymizerBean as an additional module in the Module tab page.
    Permitted values for the code page are the existing charsets of the Java runtime. According to the SUN specification for the Java runtime, at least the following standard character sets must be supported:
    US-ASCII
    Seven-bit ASCII, also known as ISO646-US, or Basic Latin block of the Unicode character set
    please refer sap.help:
    http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
    thanks,

  • How can pass information between 2 par file in iView???

    Hello,using PDK i've have created an iview calling 2 .par file, the first par file contains a menu that the user selects a products and then when press load button generates a table with information. The table with information is generated in second .par file, that collects the information passed by the menu (through beans) and with a BAPI generates the table. I made it because the menu must be separated in one frame, and the table in other...(and the first frame must displace, how a html frame)
    The question, how can pass information between two par files or if are another method to made 2 frames????
    I'm using jsp,HTMLB .
    Thanks.

    Hi,
    try to have a look to the docs contained in this zip file.
    They explain how to implement a portal component, a portal service and how to implement comunication between portal components, using POM and other features.
    Maybe could be a good starting point for you
    the file is
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/component and service creation tutorial.zip
    Ciao
    Roberto

  • How java runs in command prompt and why java runs on it

    how java runs in command prompt and why java runs on it

    command prompt was used before the development of IDEs like RAD,eclipse etc.
    its still used for better understanding of the compilation and errors.
    type the java file and save the file(source file) in the bin folder of ur jdk environment with extension .java. the source file must be the one that has the main method declared.
    in the cmd prompt screen , set the path of bin folder.
    eg:C:/program files/jdk(some version)/bin/...
    for compilation,type:
    javac (source file_name).java and press enter
    for running the file:
    java source file_name

  • How can I copy programs (iWorks) and files from Time Capsule to my HD manually? The problem is that the migration assistant does not recognize my backup file and the user on the TC. (If I open the TC on finder, it it there though)

    How can I copy programs (iWorks) and files from Time Capsule to my HD manually? The problem is that the migration assistant does not recognize my backup file and the user on the TC. (If I open the TC on finder, it it there though)

    How can I copy programs (iWorks) and files from Time Capsule to my HD manually? The problem is that the migration assistant does not recognize my backup file and the user on the TC. (If I open the TC on finder, it it there though)

  • How can I explore the folders and files on my phon...

    How can I explore the folders and files on my phone from my phone (lumia 920)?

    the file system including all the data pertaining to that partition is closed on windowsphone8, unlike that of Symbian.
    the only part you will be able to see is what you would see in this post here: /t5/Nokia-Lumia/Transfer-file-for-920/m-p/1605954#M24335
    the rest is locked unless you have developer access, and even then not much as you would just use the SDK to make your applications.

  • How to trace changes in directories and files in windows using java.

    Hi,
    Want to know how to trace changes in directories and files in windows using java.
    I need to create a java procedure that keeps track of any changes done in any directory and its files on a windows System and save this data.
    Edited by: shruti.ggn on Mar 20, 2009 1:56 AM

    chk out the bellow list,get the xml and make the procedure.....     
         Notes          
    1     Some of the similar software’s include HoneyBow, honeytrap, honeyC, captureHPC, honeymole, captureBAT, nepenthes.     
    2     Some of the other hacking software’s include keyloggers. Keyloggers are used for monitoring the keystrokes typed by the user so that we can get the info or passwords one is typing. Some of the keyloggers include remote monitoring capability, it means that we can send the remote file across the network to someone else and then we can monitor the key strokes of that remote pc. Some of the famous keyloggers include win-spy, real-spy, family keylogger and stealth spy.          
    3     Apart from theses tools mentioned above there are some more tools to include that are deepfreeze, Elcomsoft password cracking tools, Online DFS, StegAlyzer, Log analysis tools such as sawmill, etc.

  • How to escape newline character(nl) in file content conversion parameter?

    Hi Experts,
    How to escape newline character(nl) in file content conversion parameter?
    For example:
    field1field2field3
    field4field5field6
    Means Item is splitted in two lines.
    I want to SKIP new line character
    and to collect all SIX fields.
    What will be the file content conversion parameter?
    Thanks in Advance..........

    Hi,
    as far as i know there is nothing in the standard. But the question is why dont you combine at mapping the fields into only structure?
    Regards,
    Udo

  • Purpose of message protocol file and file content conversion

    hi
       i am currently working in idoc to file scenario, 
          In what cases we will go file and file content conversion in message protocol for file adapter.
    can anyone specify the real significance of it? bcoz this may help me and continue my scenario in its suitable path.
    Regards
    Saravanakumar PK

    Hi,
    In XI (internal) all XML message are based on the XI Message Protocol.
    See: http://help.sap.com/saphelp_nw70/helpdata/en/b6/0b733cb7d61952e10000000a11405a/frameset.htm
    XI Protocol is nothing but an SAP XI extension of SOAP protocol and SOAP protocol is nothing but a SOAP request in a HTTP protocol. SOAP request is nothing but SOAP extension of an XML message. Hence finally it drill downs to the fact that XI message is in fact an XML message with some extra information in the header which are SAP specific like the SAP Runtime, SAP Hoplist, etc...
    File Content Conversion
    Integration Engine understands only XML messages.Now if u r handling normal text file such as 'tab separated' file,'# separated' file, or a CSV file, you need to convert the content of the file to XML and File Content Conversion mechanism helps to do this job.This File Content conversion mechanism(option)is present with the File Adapters.both Sender and Receiver.
    How to do FCC:
    http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm
    /people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
    /people/venkat.donela/blog/2005/06/08/how-to-send-a-flat-file-with-various-field-lengths-and-variable-substructures-to-xi-30
    /people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
    /people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
    /people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
    /people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
    /people/shabarish.vijayakumar/blog/2006/04/03/xi-in-the-role-of-a-ftp
    Thanks
    Swarup

  • How to move some xml element and its content to a new frame

    Hi All,
    How to move some xml element and its content to a new frame.

    Hi Chinnadk,
    Sorry my code its comment some lines. Now only I check the forum thread, you just try one more time.
    #target InDesign;
    #include "/Program Files (x86)/Adobe/Adobe InDesign CS5.5/Scripts/XML Rules/glue code.jsx"
    var myDoc = app.activeDocument;
    //____________________ XML RULE SET
    var myRuleSet = new Array (new margintag);
    with(myDoc){
        var elements = xmlElements;
        __processRuleSet(elements.item(0), myRuleSet);
    function margintag(){
        this.name = "margintag";
        //this.xpath = "//margintag[@type='mn2']";
        this.xpath = "//margintag";
        this.apply = function(myElement, myRuleProcessor){
            with(myElement){
                app.select(myElement);
                try{
                    var myPrePara = app.selection[0].paragraphs[-1].parentTextFrames[0].paragraphs.previousItem(app.selection[0].paragraphs[-1]);
                    if(myPrePara.characters[-1].contents=="\r"){
                        myPrePara.characters[-1].remove();
                    var myTextframe = myElement.placeIntoInlineFrame(["7p9","6p"]);
                    myTextframe.appliedObjectStyle= myDoc.objectStyles.item("MN1");
                    myTextframe.fit(FitOptions.FRAME_TO_CONTENT);
                    myTextframe.parentStory.paragraphs.everyItem().appliedParagraphStyle = app.activeDocument.paragraphStyles.itemByName("MN1");
                    }catch(e){}
                app.selection = null;
            return true;
    thx,
    csm_phil

  • Does anyone know how to retrieve lost mailbox folders and their contents in mail?

    Does anyone know how to retrieve lost mailbox folders and their contents in mail?

    It might be that you selected "Delete sent mail after a mont (or a week, or whatever)" in Mail Preferences. iCloud account is IMAP, so it won't keep mail in your HD. I have that problem.

  • How do I hide my mailbox and mail contents from other users, leaving other functions of my iMac accessible?

    How do I hide my mailbox and mail contents from other users, leaving other functions of my iMac accessible?

    You don't have to shut down the computer to switch accounts. All you do is click the Apple symbol in the upper left and choose Log Out and that's it. You can also set up Faster User Switching by:
    1. Open System Preferences - Accounts
    2. Click Login Options
    3. Check the box called "Show fast user switching menu as" then choose from either icon, short name or name.
    Then when someone wants to switch users they can. The advantage of this method is if you are have a document open and don't want to close it the document will remain open. If the other user attempts to shut down the computer they can't until you have logged out thereby saving all your data.
    A very simple and elegant solution.

  • HT1386 I copied my my iTunes music from an old computer to a Macbook Pro, but it did not copy the playlists on my nano. How can I transfer the playlists and their content from the nano to the Macbook

    I copied my iTunes music from an old computer to a new Macbook pro but it did not copy the playlists that are on my Nano. How can I copy the playlists and their content on the nano to the Macbook? If I automatically sync the nano from the Macbook, will it scrub the content and existing playlists on the nano?

    You need a third-party program like one of those discussed here:
    https://discussions.apple.com/message/2901170#2901170

  • How to pass a command line argument to a jsp file...

    Hi guys,
    I'm writing a jsp file in which I have some java codes. I want to pass some command line arguments to that jsp file. In other words, I have some files located somewhere on my C drive and I want to pass the path to these files to my jsp file. How can it be done? I have never done before.
    Any suggestion will be very hepful...
    Thanks....

    I dont know if I truly understand your problem...
    For instance, when you place the url of your jsp you can add, at the end some parameters. For example:
    http://myserver/myapp/myjsp.jsp?MyParameter=C:\Temp\JavaTutorial.html
    In your JSP, you can place this code on a scriplet to get the value:
    String path = request.getParameter("MyParameter");
    Hope it helps.

  • How to pass a command line argument to the sequence?

    Hi,
    My GUI is written in VB.NET. I can read the command line argument in the GUI, using: Me.AxApplicationMgr.CommandLineArguments(). But I don't know how to pass it on to my sequence file which the GUI invokes. How do I read the command line argument from the sequence file?
    My purpose, is to have the same basic sequence execute different subsequences depending on starting conditions...
    I am using TestStand 3.0 with a VB.NET GUI, on Windows XP.
    I'd appreciate any help on the subject.
    Alan

    Hi Alan,
    One obvious way would be to add parameter(s) to the MainSequence and then modify the process model sequence file to use the new parameter(s) in the step "MainSequence Callback"  in either Single Pass or Test UUTs but I wouldn't recommend this approach.
    The sequence file to be run via the entry point can be found at "RunState.ProcessModelClient" and the lookup string to the MainSequence would be "RunState.ProcessModelClient.Data.Seq["MainSequence"] or .Seq[0] .
    Therefore you could quite easy use the SetVal method to setup a Local variable in the MainSequence of your Sequence File to receive the command line string.
    Also you could do this without altering the Process Model Sequence File by using the Callback Sequence ProcessSetup in your Sequence File.
    As an example.
    You have a string in your Locals of MainSequence called CmdLineStr.
    If you add the Callback Sequence ProcessSetup to your SequenceFile, then add an ActiveX Automation Adapter step which is setup for a PropertyObject and the reference is RunState.Caller.RunState.ProcessModel.Data.Seq[0].Locals.CmdLineStr.
    There is an extra RunState.Caller to the lookup string, that's because I am doing the work in a SubSequence of Entry Point Sequence.
    The method to use is SetValString and the parameters of the PropertyObject will be
    lookupString = ""
    options = 0 or 1
    newValue = where evey you have stored you command line string.
    Now when you run your sequence file you will find that the Locals.CmdLineStr will contain your parameter string.
    Hope this is of help to you.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

Maybe you are looking for

  • Is there a way to assign the default font for font substitution?

    I use PsCS3 at home and work. I took some work home today, and SHOCK, I didn't have any of the same fonts I have on my Mac at work. Right now, I'm laboriously changing all my type layers one by one to a suitable replacement font on my PC. There's got

  • Trouble with wireless n and smb shares

    I have a bit of a per-plexer here. I have a personal mac that up until a little while ago, ran 1.5.8 flawlessly for six months since i had it. This included a lot of mounting my windows 7 file server and watching movies or listening to music over wir

  • Ask-The-Expert (ATE) Questions and Demos

    You can quickly access many of the answers and demos held during our Support Model for the Channel and Their Customers Ask the Expert (ATE) session for the Business ByDesign version of FP2.6 You can access the demo recording here; https://sap.na.pgic

  • Keeping same file name possible in Compressor 4.1.2?

    Is keeping the same file name possible in Compressor 4.1.2?

  • Problem with offset length

    Hi, i have a problem with offset length please see below code and suggest : data: content_new                LIKE soli-line.   "It has a length of 255 charecter content_new = 'MTE:SD0\nwssd01_SD0_00\CPU\CPU_Utilization'. content_new = content_new+4(2