Need help with writing to a file

I am writing a program that is a file sharing program where i read in bytes from a socket in a BufferedReader into a char[]. Then i want to write to a file using FileOutputStream which only lets me write with a byte[]. Is there a way to read in the info into a byte[] rather a char[]?

may be this code helps
import java.io.*;
public class cp
        public static void main(String args[])
                try
                File my=new File("source.txt");
                FileReader fr=new FileReader(my);
                BufferedReader br=new BufferedReader(fr);
                String a;
                FileWriter fw=new FileWriter(args[5]);
                while((a=br.readLine())!=null)
                        System.out.println(a);
fw.write(a);
fw.close();
                }catch(Exception e){}

Similar Messages

  • I had to put my computer by together without migration or time machine I NEED help with order of the files?

    I had to put my computer by together without migration or time machine I NEED help with order of the files?

    Hi, where are these other files exactly?

  • Need help with writing a rule

    Need help with some rules. I want to book a number to a specific Entity at a Specific Custom 4 only. I don't want this formula to work at all C4 levels. How can this be done?
    for example if Entity is "XBM1123" and we use C4 for tracking and the tracking level I want to book it to is IMPORT, how can this be done for a specific account 4400221
    I have my formula as
    If pov_value = "<Entity Currency>" or pov_value = "<Entity Curr Adjs>" Then
    If HS.Entity.Member = "XBM1123" or HS.Custom4.Member = "IMPORT" then
    HS.EXP "A#4400221= A#4521111 + A#3526644 + A#635210"
    End If
    End if
    this did not work. I got hte following error
    Calculate started.<BR>Error executing VBScript Microsoft VBScript runtime
    error, Line 259:Object doesn't support this property or method:
    'HS.Custom4.Member'.<BR>Calculate finished.<BR>Error executing
    VBScript %0.
    I then changed it to the below and it still did not work
    If pov_value = "<Entity Currency>" or pov_value = "<Entity Curr Adjs>" Then
    If HS.Entity.Member = "XBM1123" then
    HS.EXP "A#4400221.C4#IMPORT= A#4521111 + A#3526644 + A#635210"
    End If
    End if
    error
    Invalid Custom1 member
    specified for this function.
    Invalid Destination specified for this function:
    A#4400221.C4#IMPORT.

    You are close.
    Try:
    If pov_value = "<Entity Currency>" or pov_value = "<Entity Curr Adjs>" Then
        If HS.Entity.Member = "XBM1123" then
           HS.EXP "A#4400221.C4#IMPORT= A#4521111.C4#IMPORT + A#3526644.C4#IMPORT + A#635210.C4#IMPORT"
        End If
    End if
    or replace IMPORT with with Top_C4 or what ever member you need to copy to C4#IMPORT.
    Rule of thumb, to be on the safe side and for most simple calcs, is if you mention a dimension on the left side, you need to define it on the right side as well.

  • Need help with writing a query with dynamic FROM clause

    Hi Folks,
    I need help with an query that should generate the "FROM" clause dynamically.
    My main query is as follows
    select DT_SKEY, count(*)
    from *???*
    where DT_SKEY between 20110601 and 20110719
    group by DT_SKEY
    having count(*) = 0
    order by 1; The "from" clause of the above query should be generated as below
    select 'Schema_Name'||'.'||TABLE_NAME
    from dba_tables
    where OWNER = 'Schema_Name'Simply sticking the later query in the first query does not work.
    Any pointers will be appreciated.
    Thanks
    rogers42

    Hi,
    rogers42 wrote:
    Hi Folks,
    I need help with an query that should generate the "FROM" clause dynamically.
    My main query is as follows
    select DT_SKEY, count(*)
    from *???*
    where DT_SKEY between 20110601 and 20110719
    group by DT_SKEY
    having count(*) = 0
    order by 1; The "from" clause of the above query should be generated as below
    select 'Schema_Name'||'.'||TABLE_NAME
    from dba_tables
    where OWNER = 'Schema_Name'
    Remember that anything inside quotes is case-sensitive. Is the owner really "Schema_Name" with a capital S and a capital N, and 8 lower-case letters?
    Simply sticking the later query in the first query does not work.Right; the table name must be given when you compile the query. It's not an expression that you can generate in the query itself.
    Any pointers will be appreciated.In SQL*Plus, you can do something like the query bleow.
    Say you want to count the rows in scott.emp, but you're not certain that the name is emp; it could be emp_2011 or emp_august, or anything else that starts with e. (And the name could change every day, so you can't just look it up now and hard-code it in a query that you want to run in the future.)
    Typically, how dynamic SQL works is that some code (such as a preliminary query) gets some of the information you need to write the query first, and you use that information in a SQL statement that is compiled and run after that. For example:
    -- Preliminary Query:
    COLUMN     my_table_name_col     NEW_VALUE my_table_name
    SELECT     table_name     AS my_table_name_col
    FROM     all_tables
    WHERE     owner          = 'SCOTT'
    AND     table_name     LIKE 'E%';
    -- Main Query:
    SELECT     COUNT (*)     AS cnt
    FROM     scott.&my_table_name
    ;This assumes that the preliminary query will find exactly one row; that is, it assumes that SCOTT has exactly one table whose name starts with E. Could you have 0 tables in the schema, or more than 1? If so, what results would you want? Give a concrete example, preferably suing commonly available tables (like those in the SCOTT schema) so that the poepl who want to help you can re-create the problem and test their ideas.
    Edited by: Frank Kulash on Aug 11, 2011 2:30 PM

  • Help with writing a batch file

    Hi :
    does anyone know anyplace online that I can get help in writing batch files?? I have never worked much with batch files before....
    any help is greatly appreciated
    thnx

    I suppose, since you're in a Java forum, you need batch files to load java applications.
    If you use windows :
    go to ms console (start/run/"cmd")
    type edit mybatch.bat
    write your command to load a java application, something like
    java myclass.class
    save and exit.
    Be sure the bat file and the class are in the same folder.
    And make certain you've set the classpath, and path variables correctly.
    If this was what you needed and you need more help just ask.
    (In this case it could be better to make executable jars)
    If you wanted to know about linux batches, it works pretty the same way.

  • Help with writing, reading a file...

    I'm writing a program that writes a number to a file and then reads it again each time it is loaded. It's like a counter, the number starts out being 0, then when the program is run again the number will be two, and so on and so on. I've never been good with writing incrementer type things and files, so could you help me out? Remember, the program writes a single number to the file, and then adds one to that number each time the program is run, so it starts at zero and goes up by one each time it is run.
    -Thanks... I just came back from vacation and my Java skills are somewhat lacking :P

    open old file -> get the number -> create a new file -> write new number

  • Need help with reading XML using File Adapter

    I have created a simple BPEL process that uses a file adapter to read files containing XML messages of a simple xsd schema. But when reading the xml, I get the following error message:
    [2010/03/01 23:43:13] Invalid data: The value for variable "Receive_1_Read_InputVariable", part "revision-report" does not match the schema definition for this part.The invalid xml document is shown below: More...
    [2010/03/01 23:43:13] "{http://schemas.oracle.com/bpel/extension}invalidVariables" has been thrown. less
    -<invalidVariables xmlns="http://schemas.oracle.com/bpel/extension">
    -<part name="code">
    <code>
    9710
    </code>
    </part>
    -<part name="summary">
    <summary>
    Invalid xml document.
    According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-complex-type.4: Attribute 'doc' must appear on element 'revision-report'.
    Error::cvc-complex-type.4: Attribute 'model' must appear on element 'revision-report'.
    Error::cvc-complex-type.4: Attribute 'pubdate' must appear on element 'revision-report'.
    Error::cvc-complex-type.2.4.b: The content of element 'revision-report' is not complete. One of '{"http://xmlns.oracle.com/xmlfile":alternategroup}' is expected.
    Please make sure that the xml document is valid against your schemas.
    </summary>
    </part>
    </invalidVariables>
    It seems that there is some issue with the namespace, but even after trying out various combinations, I am not able to resolve this.
    Here the message schema (xsd):
    <?xml version="1.0" encoding="UTF-8" ?>
    <xs:schema elementFormDefault="qualified"
    targetNamespace="http://xmlns.oracle.com/xmlfile"
    xmlns:tns="http://xmlns.oracle.com/xmlfile"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="revision-report">
    <xs:complexType>
    <xs:sequence maxOccurs="unbounded">
    <xs:element name="alternategroup">
    <xs:complexType>
    <xs:attribute name="name" use="required" type="xs:string"/>
    <xs:attribute name="Desc" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    <xs:attribute name="doc" use="required" type="xs:string"/>
    <xs:attribute name="model" use="required" type="xs:string"/>
    <xs:attribute name="pubdate" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    And here is the xml file to be read by the file adapter:
    <?xml version="1.0" encoding="UTF-8" ?>
    <revision-report doc="doc2" model="model4" pubdate="pubdate5">
    <alternategroup Name="ABC" Desc="ABC-Desc">
    </alternategroup>
    <alternategroup Name="DEF" Desc="DEF-Desc">
    </alternategroup>
    <alternategroup Name="GHI" Desc="GHI-Desc">
    </alternategroup>
    </revision-report>
    Appreciate any help.
    Thanks in advance for your attention.
    Jay

    Thanks for your response.
    I am not sure if there is any easier way, but I tried out the following tool available on the net to check an xml against a xsd:
    http://tools.decisionsoft.com/schemaValidate/
    There were a few issues, that I corrected and finally had a xsd and xml that were matching and valid. I tried this out in my file reading BPEL process, but the error still remained the same!
    Here is my updated/simplified xsd and xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xs:schema targetNamespace="http://xmlns.oracle.com/xmlfile"
    xmlns:tns="http://xmlns.oracle.com/xmlfile"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://xmlns.oracle.com/xmlfile">
    <xs:element name="revision-report">
    <xs:complexType>
    <xs:sequence>
    <xs:element maxOccurs="unbounded" ref="alternategroup"/>
    </xs:sequence>
    <xs:attribute name="doc" use="required" type="xs:string"/>
    <xs:attribute name="model" use="required" type="xs:string"/>
    <xs:attribute name="pubdate" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    <xs:element name="alternategroup">
    <xs:complexType>
    <xs:attribute name="Name" use="required" type="xs:string"/>
    <xs:attribute name="Desc" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    <?xml version="1.0" encoding="UTF-8" ?>
    <revision-report doc="doc2" model="model4" pubdate="pubdate5" xmlns="http://xmlns.oracle.com/xmlfile">
    <alternategroup Name="ABC" Desc="ABC-Desc"/>
    <alternategroup Name="DEF" Desc="DEF-Desc"/>
    <alternategroup Name="GHI" Desc="GHI-Desc"/>
    </revision-report>
    I even tried the option that is available in JDeveloper to generate a sample xml from a xsd (when in the context of a Transformation activity). The xml generated by this also seems exactly like the one above.
    So, I am not able to figure out why my BPEL process errors out with the message Invalid xml document.

  • Need help with Flash CS6 swf files

    I have upgraded to Flash CS6 from CS5.  My problem is now whenever I made an swf movie, install it into an html page then upload it is doesnt show up.  I didnt have this problem with CS5.  I run it in test and it works on my computer but when I upload it it doesnt.  I have uploaded the script folder so that wouldnt seem to be the problem.  I dont know what is going wrong.  Some help would be greatly appreciated.
    Thanks
    Brent
    http://baconball.com/index2013.html

    open your fla is flash pro.
    click file>publish settings
    tick swf and html wrapper
    click file>publish
    upload the newly published swf and html to your server.
    open the newly published server html using your browser.
    any problem?  if yes, post the url to your newly published html.

  • Need help with query from .csv file

    I am trying to import a csv file with only 1 column in it.
    The column will only contain a 9 digit ID number. I want to read
    the file then use the contents to query a table to get the names
    and other information and display it. Here is what I have so far:
    <cffile action="read" file="#form.FiletoUpload#"
    variable="csvfile">
    <cfloop index="index" list="#csvfile#">
    <cfquery name="massimport" datasource="data1">
    SELECT * FROM IDTable
    WHERE CardNumber = ('#csvfile#')
    </cfquery>
    </cfloop>
    <cfoutput>#Name# #ID# #Site#</cfoutput>
    I get no errors but I am not getting any results. Just a
    blank page. Does anyone know how to query directly from a csv
    import? Thanks.

    You need to convert your file to a list somehow. Not sure if
    this is the most efficient way but, you can use the cfhttp tag to
    produce a query. Then your where clause becomes,
    where cardnumber in (#quotedvaluelist(query.column)#)
    and you won't need a loop.

  • Help with writing to a file

    First off...I'm just a student so please bear with me...
    I'm having problems with the following bit of code. I don't seem to be understanding the correct way to write to a file. It's not a complete program and my drop down box isn't set up to write yet...but I'm just trying to get SOMETHING as output to the file. Any help is appreciated! Here's my code:
    Mid-Term Test
    Programmer: Abraham Violett
    Date: 8-12-04
    Filename: MowersInc.java
    Purpose: This will be a data entry and retrival system
    for a
    small lawn mowing company.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MowersInc extends JFrame implements ActionListener
    JLabel blankLabel = new JLabel("");
    JLabel titleLabel = new JLabel(" Mowers Incorporated");
    JLabel firstNameLabel = new JLabel("First Name:");
    JTextField firstNameTextField = new JTextField(15);
    JTextField lastNameTextField = new JTextField(15);
    JLabel lastNameLabel = new JLabel("Last Name:");
    JComboBox lawnSizeCombo = new JComboBox();
    JButton submitInfoButton = new JButton("Submit");
    JButton clearInfoButton = new JButton("Clear");
    DataOutputStream output;
    public MowersInc()
    super("Mowers Inc.");
    try
    output = new DataOutputStream(new FileOutputStream("customers.dat"));
    catch(IOException io)
    JOptionPane.showMessageDialog(null, "Could not create storage location.", "Error", JOptionPane.INFORMATION_MESSAGE);
    System.exit(1);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    public void actionPerformed(ActionEvent e)
    String arg = e.getActionCommand();
    int fee;
    if (e.getSource() == lawnSizeCombo)
    switch (lawnSizeCombo.getSelectedIndex())
    case 0:
    fee = 50;
    break;
    case 1:
    fee = 75;
    break;
    default:
    break;
    if(arg == "Submit")
    try
    output.writeUTF(firstNameLabel.getText());
    output.writeUTF(lastNameLabel.getText());
    catch(IOException io)
    JOptionPane.showMessageDialog(null, "Could not create storage location.", "Error", JOptionPane.INFORMATION_MESSAGE);
    System.exit(1);
    public Container createContentPane()
    lawnSizeCombo.addItem("Please select Lawn Size...");
    lawnSizeCombo.addItem("Lawn less than 1000 sq/ft.");
    lawnSizeCombo.addItem("Lawn more than 1000 sq/ft.");
    lawnSizeCombo.addActionListener(this);
    JPanel mainPanel = new JPanel();
    mainPanel.add(titleLabel);
    mainPanel.add(blankLabel);
    mainPanel.add(firstNameLabel);
    mainPanel.add(firstNameTextField);
    mainPanel.add(lastNameLabel);
    mainPanel.add(lastNameTextField);
    mainPanel.add(lawnSizeCombo);
    mainPanel.add(blankLabel);
    mainPanel.add(submitInfoButton);
    mainPanel.add(clearInfoButton);
    lawnSizeCombo.setToolTipText("Select the appropriate lawn size from this list.");
    mainPanel.setLayout(new FlowLayout());
    //mainPanel.setLayout(new GridLayout(6, 2, 10, 10));
    return mainPanel;
    public static void main(String args[])
    MowersInc test = new MowersInc();
    test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    test.setContentPane(test.createContentPane());
    test.setSize(200, 215);
    test.setVisible(true);
    //lawnSize.addItem("Less than 1000 sqr/ft.");
    //lawnSize.addItem("More than 1000 sqr/ft.");
    }

    Use a program development method called Stepwise
    Refinement. Start out with a small working program.
    Then expand it little by little and in each step make
    sure that it works and you understand why. Very soon
    you have a big working program. Try it, it always
    works -:)Pay heed to UlrikaJ -:) sweety's advice, you'll be happy! ;-)
    UlrikaJ cutie would you like to go out with me someday? : )

  • Need help with converting a Divx file

    I am having a **** of a time converting a Divx file to use in FCP.
    This is the file I am trying to work with: http://www.archive.org/details/F6FHellcat_PilotInstruction (It's the 164 MB Divx file)
    While I have downloaded other Divx files from the same site and used QT to convert them to QT movies, this file is not playable by QT or a number of other programs.
    The only program I have found that plays this file is VLC.
    When trying to convert to a QT file, VLC is unsuccessful at everything EXCEPT changing the container to QT.
    When I change the container, I get a QT file that is playable in QT and FCP, but it does not have audio. This is not a big deal.
    The bigger problem is that when I play the new file in QT, the duration matched that of the original file.
    When I import the file into FCP, the duration is 2 minutes shorter. The last 2 minutes are missing!
    I'd appreciate any suggestions you may have on how to get a usable file from the original.
    Thanks.

    If the audio is no big deal, you can use Wondershare Video Converter, but it will set you back 40 clams.
    You can download a free trial from their site.
    http://www.dvd-ripper-copy.com/video-converter-mac.html
    I got it to convert successfully and it imported into FCP completely intact...but without audio.

  • I Need Help With Premiere Pro CC File Issue

    When I shoot video with my Canon XF100 camera for an extended period it creates new files every 5 minutes. In a continous shoot it keeps these separate files in a sub-folder until I hit the stop button. When I recommence shooting it creates a new sub folder and a new file.
    Until recently Premiere Pro CC would read each file seperately in a sub folder but just recently it has started to combine them all. For example, if I was shooting continuously for 15 minutes I would get three 5 minutes filesand Premiere Pro CC would normally see 3 separate 5 minute files with their own file names but just recently it will see 3 files, each 15 minutes in lenghth, and each with the same content even though they have different file names.
    Has anyone else experienced this and, if so, do you have a solution?
    Thanks,
    Milton

    This was an unintended result of an intentional change to fix how Premiere Pro handles spanned MXF clips. To learn a bit more, please consult this thread: http://forums.adobe.com/thread/1358012?tstart=0
    Look for the workaround recommended by PPRO developer Wil Renczes.

  • Need help with reading a midi file!!!

    I want to be able to make a java program that can read midi files. I need to know what notes are played and when. how can i do this.
    A bit of code would be nice to to use as a resource.
    thnx

    http://java.sun.com/products/java-media/sound/
    There are links to code samples and maybe a tutorial

  • Need help with emailing a pdf file

    how do i upload a finished pdf file to send in an email?

    When you open your document using Adobe Reader, you will see a toolbar when on the top when you tap gently on the document.
    Tap on the second icon from right to share your document via email or any other application.
    Hope this helps.
    Thanks,
    Adobe Reader Team

  • Need help with integrating a dreamweaver file and an edge file

    Alright so I have been trying to do this for far to long so I am asking for some help this is for a web design class.
    I am trying to either import a edge composition to a dreamweaver file or use the publish file from the edge file to make a completed website by adding a css navigation bar from an external css file. I want to have the css menu to the left of the logo. I have tried this numerous times but either the menu doesn't show up and is either behind the edge stage or its not there at all. When I tried it from a fresh html page and imported it from an oam file the images from the stage never showed up and I am unsure how to fix that.
                                                                ^right there.
    Here are the files
    Dropbox - Archive.zip
    Thanks for the help.

    I found the z-index for the edge animate code and it was set to 0 and i set the menu div to 40 but nothing happened and it didn't show up. This where i set the menu to a higher value and I'm not sure if this is correct, I also tried it in the css file but that also didn't work.
                <div id='cssmenu' style="z-index:40;">
      <ul>
       <li><a href='index.html'>Sell Cards</a>
          <ul>
             <li><a href='#'>Pricing Guide</a></li>
             <li><a href='buyList.html'>Buy List</a></li>
          </ul>
       </li>
       <li><a href='#'>Sealed Product</a>
          <ul>
             <li><a href='Promotional Items'>List of Sets</a></li>
             <li><a href='#'>Promotional Items</a></li>
          </ul>
       </li>
       <li><a href='#'>Other Games</a></li>
       <li><a href='supplies.html'>Gaming Supplies</a></li>
    </ul>
    </div>

Maybe you are looking for

  • Need help.. can someone look at code..

    and tell me what is happening, or rather not happening and why.... This is a neat clock that shows current time and zulu time with a disclaimer popup..... Would like to get it working to put on my site but can not figure it out. It is made up of two

  • How do I get a larger font in the Tabs and Adress bar?

    I have poor eyesight and when I open Firefox the Tabs Bar and the address bars is to small for me to read. I have to use a magnifying Glass to read them and than up close.

  • New iPhone, no computer backup but iCloud

    I just got a new iphone and didn't have a computer back up, it was synced to icloud.  Now I can't get my data off iCloud because it is a synced device.  What do I do to get my stuff back?

  • Inserting and retrieving Word docs from a custom table with LOB column

    Hi, I'm sure I'm not looking around in the right place for some docs on this. Basically I need to build a custom interface in Web PL/SQL to allow a MS Word doc to be uploaded for a user's browser and also a mechanism to retrieve the doc. Not sure wha

  • 12c Cloud Control Alert Log Purge Error

    I'm trying to purge old alert log events in EM 12c, but i'm getting error - The alert(s) could not be purged. Please ensure you have Edit privileges on this target while purging. What's i'm doing wrong? Cant find anything close to this in EM document