Question on FileWriter and byte requestBytes[]

if I have string Content, I can use the following code to write them to csv file
byte requestBytes[] = Content.getBytes();
ByteArrayInputStream bis = new ByteArrayInputStream(requestBytes);
res.reset();
res.setContentType("application/text");
res.setHeader("Content-disposition","attachment; filename=" +"temp.csv");
byte[] buf = new byte[1024];
int len;
while ((len = bis.read(buf)) > 0){
res.getOutputStream().write(buf, 0, len);
bis.close();
res.getOutputStream().flush();bu tif I don't want to use string to collact data , I wan to use FileWriter fw = new FileWriter(filename);
fw.append("Employee Code"); what can I do? in order to write them into a download able file ?
thnak you!

HJava wrote:
if I have string Content, I can use the following code to write them to csv file
byte requestBytes[] = Content.getBytes();
res.reset();
res.setContentType("application/text");
res.setHeader("Content-disposition","attachment; filename=" +"temp.csv");
res.getOutputStream().write(requestBytes);
res.getOutputStream().close();
Done. Dusted. Finished. You don't need all that other rubbish.
but if I don't want to use string to collact data,What string?
I wan to use FileWriter fw = new FileWriter(filename);
fw.append("Employee Code"); what can I do? in order to write them into a download able file ?Don't use a FileWriter. Use a FileOutputStream 'fos' and call fos.write(requestBytes).

Similar Messages

  • Pixel operation question regarding ints and bytes

    Hello,
    Im using this:
    public static void setR(int[][] pixel, int xIndex, int yIndex, int value)
              value = (value & 0xff);
              pixel[xIndex][yIndex] = (value << 16) | (getG(pixel[xIndex][yIndex]) << 8) | getB(pixel[xIndex][yIndex]);
    to set the r, g, and b values of a packed int RBG pixel. But every time I do it, it ends up flipping the bits. For example, the int value of a pixel starts as -5354668 and turns into 5354667. Is there some casting that I have to do, or conversion?
    -Thanks

    Well, I got it to work using this:
    int r = (data[row] & 0x00ff0000) >> 16;
         int g = (data[row] & 0x0000ff00) >> 8;
         int b = data[row] & 0x000000ff;
         r = 256 - r;
         g = 256 - g;
    b = 256 - b;
         data[row] = data[row] & (0xff00ffff);
         data[row] = data[row] + (r << 16);
         data[row] = data[row] & (0xffff00ff);
         data[row] = data[row] + (g << 8);
         data[row] = data[row] & (0xffffff00);
         data[row] = data[row] + b;
    It inverts the image, to a "negative." I think it had to do with the alpha bytes, so thanks to whoever mentioned that. I took out any submethods I was using. Still, I dont know why my actual params were the twos complement of the passed param....

  • Three questions about Java and Ftp

    Hello, i've the following questions about Java and Ftp:
    1- .netrc file is in $HOME directory but i can't access to this directory from java code. The following line producesan Exception (directory doesn't exists)
    FileWriter file = new FileWriter ("$HOME/.netrc");
    2- .netrc file must have the following permissions: -rw- --- --- but when i create the .netrc file the following permissions are on default: -rw- r-- r--, how can i change this permissions? (In java code, i can't use chmod.....)
    3- Are there any way to pass parameters to a .netrc file? If i get to do this i needn't change the permissions because i can't modify or create/destroy this file.
    Thanks in advanced!!!
    Kike

    1- .netrc file is in $HOME directory but i can't
    access to this directory from java code. The
    following line producesan Exception (directory
    doesn't exists)
    FileWriter file = new FileWriter ("$HOME/.netrc");$HOME would have to be replaced by a shell, I don't
    think you can use it as part of a legal path.
    Instead, use System.getProperty("user.home");
    Ok, thanks
    2- .netrc file must have the followingpermissions:
    -rw- --- --- but when i create the .netrc file the
    following permissions are on default: -rw- r--r--,
    how can i change this permissions? (In java code,i
    can't use chmod.....)Yes, you can: Runtime.exec("chmod ...");
    I need to use estrictly the .netrc with -rw- --- --- permissions
    Yes, i can use Runtime.exec ("chmod ..."); but i don't like very much this solution because is a slow solution, am i right?
    3- Are there any way to pass parameters to a.netrc
    file? If i get to do this i needn't change the
    permissions because i can't modify orcreate/destroy
    this file.I don't think so. Why do you need the .netrc file in
    Java at all? Writing a GUI frontend?I want to use automatic ftp in a java program and FTP server, the files and path are not always the same, so i can:
    - modify .netrc (for me is the complex option)
    - destroy and create a new .netrc (is easier but i have permissions problem)
    - use .netrc with parameters but i haven't found any help about it
    Thanks for your prompt reply!!!!
    Kike

  • Question regarding battery and warranty

    Hi all! I have a quick question about how and if my warranty applies to my battery. After about a year and a half of ownership (I have the three-year extended warranty), my battery has gone completely down the toilet. It wasn't a problem before, but this year I have to lug my T61p around a lot for lab work. My battery is now rated at... 39.75Wh when it shipped at 84.24Wh. This is a pretty drastic difference. In any case, I don't think that this is covered by warranty, but figured that I'd ask before I drop $180 on a new battery (ouch). And, speaking of, if my suspicions are correct, does anybody know where I might find a 9-cell battery for the T61p? All I'm seeing on Lenovo's website is the one for the N100... which doesn't... match very well. Yaknow.
    Thanks a lot!
    ThinkPad T61p [June 2008]: 2.5Ghz Penryn Core 2 Duo, 4GB DDR2 RAM, NVidia Quadro FX 570m 256MB, 160GB 7200RPM Fujitsu HDD, 1920x1200 WUXGA Matte LCD, Windows 7 RC1

    Is either of these appropriate? I'm wary of the one on Amazon, as there are other (off-brand) batteries that are advertised as being Lenovo ones (though those generally sell for  a lower price). The other one just looks like I'll have to call up to buy it.
    http://www.amazon.com/Lenovo-43R9255-ThinkPad-Notebook-Battery/dp/B001DX9EKA
    http://affordablepcsupply.com/products/IBM/REF/42T4511.html
    Thoughts?
    ThinkPad T61p [June 2008]: 2.5Ghz Penryn Core 2 Duo, 4GB DDR2 RAM, NVidia Quadro FX 570m 256MB, 160GB 7200RPM Fujitsu HDD, 1920x1200 WUXGA Matte LCD, Windows 7 RC1

  • Question regarding roaming and data usage

    I am currently out of my main country of service, and as such I have a question regarding roaming and data usage.
    I am told that the airplane mode is sufficient from keeping the phone off from roaming, but does this apply to any background data usage for applications and such?
    If the phone is in airplane mode, are all use of the phone including wifi and application use through the wifi outside of all extra charges from roaming?

    Ann154 wrote:
    If you are getting charged to use the wifi, then it is possible.  Otherwise no
    Just to elaborate here, Ann154 is referring to access charges for wifi, which is nothing to do with Verizon, so if you are using it in a plane, hotel, an internet cafe etc that charges for Wifi rather than being free .   Verizon does not charge you (or indeed know about!) wifi usage, or any other usage that is not on their cellular network (such as using a foreign SIM for example in global phones)  So these charges, if any, will not show up on the verizon bill app.  Having it in airplane mode prevents all cellular data traffic so you should be fine

  • Question regarding MM and FI integration

    Hi Experts
    I have a question regarding MM and FI integration
    Is the transaction Key in OMJJ is same as OBYC transaction key?
    If yes, then why canu2019t I see transaction Key BSX in Movement type 101?
    Thanks

    No, they are not the same.  The movement type transaction (OMJJ) links the account key and account modifier to a specific movement types.  Transaction code (OBYC) contains the account assignments for all material document postings, whether they are movement type dependent or not.  Account key BSX is not movement type dependent.  Instead, BSX is dependent on the valuation class of the material, so it won't show in OMJJ.
    thanks,

  • **question regarding 3G and wif**.

    I have a question regarding 3G and wifi. I have #G activated as well as wifi, when I go to retrieve mail for example I get a pop up asking me if I want to connect to a wifi network…should I have wifi and 3G activated at the same time, and why am I getting the pop up…
    Thanks

    You can have them on at the same time, but they will not be used at the same time for data. The order of preference for data is WiFi > 3G > EDGE > GPRS. You're getting the pop up, most likely, because you have Settings > Wi-Fi > Ask to Join Networks set to ON. You can set that to OFF, and the iPhone will still join known (i.e. previously used) WiFi networks automatically.

  • Question regarding Dashboard and column prompt

    My question regarding Dashboard and column prompt:
    1) Dashboard prompt usually work with only for columns which are in subject area. In my report I've created some of the columns which are based on other columns. Like I've daysNumber column that is based on two other columns, as it calculates the difference of two dates. When I create dashboard prompt I can't find this column there. I need to make a prompt on this column.
    2)For one of the column I've only two values 1 and 0. When I create prompt for this column, is it possible that in drop down list It shows 'Yes' for 1 and 'No' for 0 and still filter the request??

    Hi Toony,...
    I think there was another way of doing this...
    In the dashboard prompt go to Show option > select SQL Results from dropdown.
    There you need to write your Logical SQL like...
    SELECT CASE WHEN 1=0 THEN PERIODS.YEAR ELSE difference of date functionality END FROM SubjectAreaName
    Here.. Periods.Year is the column which is already exists in repository's presentation layer..
    and difference of date functionality is the code or formula of column which you want to show in drop-down...
    Also write the CASE WHEN 1=0 THEN PERIODS.YEAR ELSE difference of date functionality END code in fx of that prompt.
    I think it helps you in doing this..
    Just check and inform me if it works...
    Thanks & Regards
    Kishore Guggilla
    Edited by: Kishore Guggilla on Oct 31, 2008 9:35 AM

  • Questions on SPINCOUNT and Semaphores

    Hello,
    I have a few more questions on SPINCOUNT and semaphores.
    1) The documentation states that SPINCOUNT = 0 (default) uses the spincount "built into the delivered binary".
    - How can I find out what the built-in spincount is?
    - What is the built-in spincount for a native client?
    2) "Semaphore appears stuck" (Q_CAT 1447) is reported when the semaphore for a queue cannot be obtained.
    - Does SPINCOUNT also apply to queue semaphores?
    - What is the timeout for the semop? Ie, how long does a process wait before reporting 1447?
    3) Is there a similar (to Semaphore appears stuck) error for other semaphores, such as GTT, AOM, etc)?
    - If yes, what is the timeout?
    Thanks...
    Roger

    Roger,
    1) The default SPINCOUNT value is 0 (no spinning) for all platforms that are supported today. (At one time we had a default value of 5000 for Sequent hardware, but it has been many years since we supported that platform.) The SPINCOUNT value that will work best for any application depends on many factors, including the number of CPUs on the machine, the hardware platform, and the indvidual application. SPINCOUNT will only be useful when the machine has more than one CPU.
    2) /Q logs Q_CAT:1447 after 50 unsuccessful attempts to obtain the semaphore when the semaphore has never been released and reobtained by a different process or the same process during that period. The Access Control List code uses the same rule for logging LIBTUX_CAT:1511. If TMSPINCOUNT is set, then the number of unsuccessful attempts to obtain the semaphore is incremented by 1 only after TMSPINCOUNT spins have been done.
    Code for the BB semaphore and the semaphore used by /Domain follows a different rule. This code will log LIBTUX_CAT:5005 or LIBGW_CAT:5010 if a process has to wait for the semaphore for 10 seconds and the semaphore has never been released by the original owner during this time period.
    3) TMSPINCOUNT is used for the BB semapahore, AOM semaphore, ACL semaphore, /Domain semaphore, and /Q semaphore. Locking the GTT uses the same BB semaphore that used to lock other tables in the BB.
    Regards,
    Ed

  • Some questions on whitespace and &

    Dear all,
    I have some questions on whitespace and & that need you kind help:
    1. Except /n /t /r and space, is there any characters that are whiteSpace characters?
    2. When parsing XML document, when the ignorableWhitespace() method is called? Will it be called from characters() ?
    e.g. Where the white space after <a> is called, and where is the white space between test1 and test 2 indied <b> is called?
    <a>
       <b>test1 test2</b>
    </a>  3. When the & should be escaped in a well-formed (or validated) XML file by replacing &?
    It should be excaped in any element content, such as <b>test1 & test2< /b> - except for <![CDATA[ section?
    It should NOT always be used in attributes? e.g. <a b="test1 & test2"/>  - has to do escaped by entity & - am I right?
    Thanks!
    Thanks
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thanks DrClap.
    >
    2. When parsing XML document, when the
    ignorableWhitespace() method is called? Will it be
    called from characters() ?It will be called when the document has a DTD and the
    parser is a validating one that is actually
    validating, when the parser sees whitespace that is
    not part of a DTD element. It will not be called from
    characters() because that is a method that you write.I wrote a contentHandler and using Xerces parser to parse an XML document. When I set validating feature to false, I found that for:
    <a>
       <b>test1 test2</b></a>The white space between <a> and <b> (including newline) is actually called from characters(), not in ignorableWhitespace(). So does this mean that if validating - white space is always called from ignorableWhitespace(), and if not validating, if it is always called from characters()?
    >
    3. When the & should be escaped in a well-formed(or
    validated) XML file by replacing &? The XML Recommendation says "The ampersand character
    (&) and the left angle bracket (<) may appear
    in their literal form only when used as markup
    delimiters, or within a comment, a processing
    instruction, or a CDATA section. If they are needed
    elsewhere, they must be escaped using either numeric
    character references or the strings "&" and
    "<" respectively."So in this sense, both & in <b>test1 & test2< /b> and <a b="test1 & test2"/> is illegal unless replacing them by & - right? What does the markup delimiters mena in above XML Recommendation ? Example?
    Thanks!

  • Few questions on Templates and Favorites

    Experts,
    Few fundamental questions on Templates and Favorites...
    1) Can Favorites be shared with other users?
    2) Can Templates be transported across systems (Dev or QA or PRD) ?
    3) Can Templates be shared across planning area ( Yes, KF names are same across planning area?
    Any insights appreciated!!!
    Thanks
    Krishna

    Hello Krishna
    1. No, favorites are user specific and are not shared. Templates are.
    2. There are no transports in the traditional sense in S&OP. So a Template can't really be transported. What you can do, however, is open a Template in DEV, for example, then log off and log back on - just this time to QA or PRD. This assumes you have the same planning area, KF etc.in each system. Now you can add it to the templates in QA or PRD ... this is how you get it from one system to another.
    3. I believe they are not shared between planning areas. If you make a planning area copy, I think they might come over but if you built a new PA2 from scratch, the ones you have in PA1 won't be there. If you want to get a planning view template from one PA to another, you basically follow the steps as in my answer to your second question. Again, for sharing a planning view Template between Planning Areas the attributes, time profiel and key figures you use have to be the same.
    Hope this helps,
    Jens

  • Questions on photos and storage

    I have a few questions about photos and storage... If you can just answer one of these, that's fine and thanks for the help!
    How do I see how much space my iPhoto photos are taking on my hardrive?
    I have Time machine which backs up, but concerned that I'm getting too many pictures.  When I do "Get Info" on the hardrive it says 640GB Capacity with 254GB used. I'm assuming that includes all my photos, and that Time machine only backs up and is not the active storage for those photos?
    What is advisable for available GB space on this size computer?
    I have my photos on the hardrive and the time machine, is it also advised to have in a cloud-based storage system to be safe? Or some other place.  Just checking what others do with this.

    1 - it is a really good idea to start new threads with new questions - threadjacking a year old solved thread on a totally different subject will not provide the best coverage and the best answers
    2 - Do NOT uncheck the option to copy imported items to the iPhoto library - it is a really, really bad idea that will create many problems for yo and has no advantages of any sort - see the user tip on file management in iPhoto for more details - iPhoto and File Management
    3 - take the time to learn how to use iPhoto and the concept of using a database for management photos rather than a file based system like you are used to - it is much different and much more powerful - but there is a learning curve and a different thought process
    4 - yes you can always export anything or everything from iPhoto for use on any other system - see the user tip on exporting for details - Exporting From iPhoto
    5 - always remember that you never access your photos directly - iPhoto totally replaces the finder for managing your photos - see the user tip on accessing photos for more details - How to Access Files in iPhoto
    LN

  • HT5312 I didn't make a rescue e-mail and now i forgot the answers of my security questions!!' And the apple support contact wont open???

    I didn't make a rescue e-mail and now i forgot the answers of my security questions!!' And the apple support contact wont open???

    I'm not sure what you mean by the 'apple support contact wont open' (?). If you mean the 'contact iTunes Store support' link on the page that you posted from I've just tried it and it seems to wok ok for me, though I haven't gone as far as to actually contact them.
    You can contact either iTunes Support or Apple to get the questions reset.
    e.g. you can try contacting iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Account Management , and then 'Forgotten Apple ID security questions'
    or try ringing Apple in your country and ask to talk to the Accounts Security Team : http://support.apple.com/kb/HE57
    When they've been reset you can then use the steps on the page that you posted from to add a rescue email address for potential future use, or if it's available in your country you could change to 2-step verification : http://support.apple.com/kb/HT5570

  • I have no clue as to what my security question answers are and since this is my first purchase from my mac book it is asking for these. What do i do?

    I have no clue as to what my security question answers are and since this is my first purchase from my mac book it is asking for these. What do i do?

    You won't be able to change your rescue email address until you can answer 2 of your questions, you will need to contact iTunes Support / Apple to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset you can then use the steps half-way down this page to update your rescue email address for potential future use : http://support.apple.com/kb/HT5312

  • A question about grub and USB

    Hi All
    I have a quick question about grub and USB that I can't quite find the answer to by searching.   Most of the FAQs discuss booting a full linux dristribution from USB. My situation is this.  I am getting a new computer with two drives, the second will be arch and the first will be Vista (for my wife).  I want the computer to boot the same way that my wife's machine boots at work so I don't want to install grub on the MBR.  So, is there a way to have all of the grub config files and kernels installed on the second drive and simply install to grub boot loader to the MBR of a USB stick?  My goal would be to simply plug the USB stick into the new PC and boot arch from the second drive. 
    Thanks
    Kev

    i cant say for hp's
    havent worked on any in a while
    recent machines have been coupleof dell's , vaio & emachine
    which dells do offer it at least the ones i tried , my laptop does(dell)
    all home pc's are built by me which do offer to boot individual drives
    what hp you getting it may tell in specs
    are both discs sata? if so it might not offer this option with 2 drives of same interface
    check your power supply alot of these preconfigured machines put cheap under reated power supplies in there
    & will burn your motherboard i just replaced PS(250 watt) & mobo(845gvsr) in an emachines <cheap stuff<
    i hope you researched the pc before buying ie : mobo, power supply are the biggest concerns
    i find it much more benificial to build my own machine gives me peace at mind. the cost is sometimes more in $ but not always , your biggest expense is time researching hardware
    if you live in usa the best places to start looking are bensbargains.net & pricewatch.com
    i am not affiliated with either & niether sell the hardware they are just advertisers a place to buy
    for costomized machines that i would trust is unitedmicro.com theyll asemble & test before shipping
    i have gotten 2 machines so far from them with NO PROBLEMS with hardware (knock knock)
    you may want to consider this in your next venture for pc

Maybe you are looking for

  • I need to store a schema in mds in soa 10g.

    Hi Gurus, Kindly help out with the present situation. i need to store the schema which is used in different process in the mds in soa 10g. can any one provide some steps or docs related to setting up of mds in soa 10g? Help is greatly appreciated. Re

  • Error Connecting to VGA2USB FrameGrabber in LabView

    I'm trying to connect a VGA2USB frame grabber device.  It uses DirectShow, and is recognized in MAX by the IMAQdx driver.  However I get an 0xBFF69011 error when trying to connect to it.  I ran the camera validation utility and it appears that I am g

  • Issue with PC not booting when PCIe 8360 attached to controller PXI 8360

    I am using a PCIe 8360 in our Windows 7 PC and connecting it to a PXI 8360 controller in a Pickering chassis.  When I connect the mxi card to the controller and try starting the PC, the PC will not boot.  Has anyone seen this issue and if so, what is

  • Apps icon disappear when i open it

    Hello, When i open an app (either from the dock or the all folder) the icon of the specific app disappear tha app is working normally, but the icon is not visible.

  • Video Tutorials for Mac?

    I have a friend is new to Elements (and digital photo editing in general). She's the sort of person who learns better from 'seeing' rather than from 'reading'. Ideally a class would suit her, but there aren't any running in her locality, and I'm too