I want the Bytes opened as Bytes not Characters ?

Hi,
Here is my assignment main points:
1. Get File:
I use file = fd.getSelectedFile(); to get the file content, and
String filename = file.getName(); to get the file name
Two things must be sent to the Server; the file name and the file content.
2. Sending the file to Server:
//Get a reference to the socket's output streams
DataOutputStream os = new DataOutputStream(socket.getOutputStream());
//Opens the requested file.
FileInputStream fis = null;
boolean fileExists = true;
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException e) {
fileExists = false;
if (fileExists)
//Construct a 1K buffer to hold the bytes on their way to the socket
byte[] buffer= new byte[1024];
int bytes = 0;
//Copy requested file into the socket's output stream.
while((bytes = fis.read(buffer)) != -1)
os.write(buffer, 0, bytes);
// Close the file
fis.close();
*The file has been sent to the Server as a Byte Buffers through DataOutputStream
3. Open the file in Server side:
// Receive the file
InputStream is = client.getInputStream();
BufferedReader breader = new BufferedReader( new InputStreamReader(is));
// Read the file as String
String line;
StringBuffer builder = new StringBuffer();
while ( (line = breader.readLine()) != null){
builder.append(line);
builder.append(" ");
String text = builder.toString();
*The file has been opened as a text .
4. Print the File:
printText( text );
The file has been printed as a text .
Problems I faced are:
1. I dont know how to send the file name + file content, now I can just send the content of the file, I know that some modification must be done in 2. Sending the file to Server, but I don't know how?
2. I dont want to recieve the file in Server side as text, instead I want to recieve it as a bytes so I can print any type of file, how to do that?
Any Advice? or sample code ?
Thanks in advance.

I don't see the problem. Use DataOutputStream's writeUTF and DataInputStream's
readUTF for the filename and write and read bytes for the filecontent. Don't
use Readers or Writers.

Similar Messages

  • I want the gold security padlock back, not your color codes, otherwise I will return to Internet Explorer

    I want the gold security padlock back, not your color codes, otherwise I will return to Internet Explorer

    Install this add-on: https://addons.mozilla.org/en-US/firefox/addon/padlock-icon/
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • TS3899 IPad Air, Mail, I want incoming e-mails to be displayed as previews that I must click to open. I do not want the already opened e-mail view on the left of my mailboxes. Lu

    I know how to delete an e-mail. That is not my question. On my Mac and iphone my email view is of preview of e-mails that I then click to open If I want to read them. I want the same mail view on my I-pad. So that I can delete possible spam mail without opening the e-mail. How do I change the view settings for my mail on my I-pad?

    Sorry, you can't. The default mail app always has a mail open. The only way around it is to always have an older mail selected so that it's open, not the newer ones.
    or look for another app. I'm afraid that I have no recommendation to make.

  • Indesign CS4 double click the file opens app. but not file

    One of our systems that is running Win XP Pro SP3 with InDesign CS4 loaded and file associations fixed, when an INDD file is double clicked the application opens but the file does not. If we open INDD and go to file open and select the file it opens. Just not when double clicked. If I put the file on another system everything is fine. Anyone seen this before.

    I'm pretty much at a loss. You might want to make sure that the open action is programed correctly in Windows.
    Open Explorer and go to Tools > Folder Options... and scroll to .indd, then click the advanced button and select the Open action. Click Edit, and make sure that the "Application used to perform action" line includes "%1" (in quotes) after the path to InDesign. I believe the "confirm open after download" box should also be checked in the edit screen.
    If that's OK, I'm guessing it has to do with SP3. Doe you have SP3 installed on the machine where it works?

  • I can't open my iphoto. When I click on it the screen opens but will not load.

    I can't open my iphoto. When I click on it it opens the screen but will not load. Can't see any of my pictures. HELP!

    It's Iphoto '11 version 9.2.1

  • Due to my account being hacked, I changed my Apple ID, I did not create a new account.  Now my software updates want the old ID but will not accept the password.  How can I update built in software.

    My orginal Apple ID was hacked, so I changed my Apple ID.  I did not create a new ID.  I have changed my ID on my profile on my MacBook Pro.  However now I have an update for factory installed software iPhoto and iMovie that is asking for the old ID.  How can I get the updates or force them to use the new ID that I am using for every other Apple product I own.

    You'll have to talk to Apple about AppleID and account issues, we are just other users here.

  • When in Firefox 4 I marked the menu bar to be visible, I want the backgound to be solid, not see-through.

    The background color for the url line and menu bar on my Firefox 4 is see-through, not solid. I can see my desktop in the background in those locations. How do I get a solid color background?
    Please respond to [email protected] I had to use an old email address to register as they offered no opportunity to change to user name and my standard user name apparently did not work.

    Try this change through the Windows Control Panel
    Control Panel\All Control Panel Items\Personalization
    at the bottom Window color
    Transparency turn off, and adjust color characteristics.
    http://dmcritchie.mvps.org/icons/w7_window_color_and_appeance.png
    If things are okay after that then I guess your problem is fixed; otherwise, continue.
    Transparency in Firefox just because you have Windows 7 is the pits, especially when you've tried to go out of your way to turn transparency off in Windows 7.
    You could install a Persona, but most of those make the toolbars almost as hard to read as the transparency. But there are some light pastel colors that might work.
    I add some color to the menu bar, and more grayish on the navigation bar, and almost white on the tabs bar using styles. Originally it was just the menu bar and the background for dialogs so that I could distinguish one profile from another.
    You must install "Stylish" extension in order to use styles at least it make things easier than using userChrome and restarting Firefox with each little tweak.
    Actually in looking at the before and after picture perhaps you don't have transparency turned off in Windows 7.
    Adjust the color and transparency of the window borders. This option allows you to change the appearance of window borders to make them easier to see.
    If the change in the control panel did not work...
    If that doesn't fix it, this is what I was referring to:
    * [https://addons.mozilla.org/en-US/firefox/addon/stylish/ Stylish :: Add-ons for Firefox]
    * [http://userstyles.org/styles/9514 Color Toolbar(s) to identify profile (DM*) - Themes and Skins for browser - userstyles.org]
    * [http://userstyles.org/styles/24728 Tab Color Underscoring active/read/unread (Fx3.6) - Themes and Skins for browser - userstyles.org]
    * [http://userstyles.org/styles/9043 Tabs Bar Minimal Size - Themes and Skins for browser - userstyles.org]
    * [http://dmcritchie.mvps.org/windows-7/win7.htm Windows 7 Home Premium]
    * http://dmcritchie.mvps.org/icons/fx4toolbars.png fx4toolbars.png -- before and after picture (PNG Image, 915x326 pixels)]
    Here's a little test, sometimes like less than 5% of the time I get my colors and good formatting. Do you see transparent background, white background, gray background.
    Chaos -- despite my changes these don't format in 4.0 as they would on 3.6.17, paste JavaScript code into location bar. Make a selection before invoking second test.
    * javascript:alert("Test%20of%20Alert%20Message%201...5...10...15...20...25...30...35...45...50...55")()
    * javascript:(function()%20{var%20str="1xxx5xxx10xxx15xxx20xxx25xxx30xxx35xxx40xxx45xxx50xxx55\r\nxray%20dog\r\n"+document.getSelection();aa=prompt("Ready%20to%20copy%20to%20clipboard\r\nexample%20Prompt4:",str);void(window.location.reload(false));})();

  • My FF crashes many a times and the last opened tabs are not restored. The Restore Previous Session under the history tab is greyed out and the the Session restore button on about:home is not there and im using FF 8.0.1

    The tabs on about:home is not there instead there are Firefox advertisements and the restore button under history is greyed out>

    Make sure that you do not run Firefox in permanent Private Browsing mode.
    *https://support.mozilla.com/kb/Private+Browsing
    To see all History and Cookie settings, choose:
    *Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    *Deselect: [ ] "Always use private browsing mode"
    See also:
    *http://kb.mozillazine.org/Session_Restore
    *https://support.mozilla.com/kb/Session+Restore

  • When i attach a portable pdf to an email, it opens and displays contents.  I want the file to remain closed - help.  thanks

    When I attempt to attach a portable pdf to an email, it automatically opens and displays in the email.  I want the file to be attached not opened.  I am new to MAC and do not understand this portable pdf concept.  Lease help.  all I want is a file to show on the email message which can be opened by the person receiving the email.

    Mail shows any single-page PDF (as well as many other document types) as a preview in an email message rather than the icon, but it is actually being attached as a normal email attachment. Unless the recipient also has Mac OS X Mail, they'll just see the PDF as an attachment unless their mail application also shows PDFs in line.
    There is a third-party product which can suppress this display so that all attachments including single-page documents just show in Mail as an icon. If that's of interest, let me know and I'll post the URL to the product. But it doesn't affect how the document is attached and the email sent, only how it displays on your system.
    Regards.

  • "An error (1502) occurred during the action Open." when opening original .VSD files, but NOT copies!?

    We have a weird situation we're trying to troubleshoot for quite a while: We have multiple .vsd files stored on our network in DFS shares.. We have multiple users who cannot open the files, when they try by navigating to the file and double-clicking it,
    they get "An error (1502) occurred during the action Open. File not found"
    However, if they copy and paste the file to the same exact network folder, THAT file they can open with no problem!
    The problem is very bizarre. I've checked obvious things such as file/folder permissions, versions of Visio installed, things in common between people who can and can't open the files.. I even did some testing today with some strange results...
    Windows 7 x64 machine with Visio 2010 Pro installed (x86):
    1. Opened file by double-clicking it in explorer, "Got the 1502 error"
    2. Tried it again, this time I just get "File not found"
    3. Opened Vizio, did a File --> Open --> navigated to the file and opened it that way... 1502 error.
    4. Copy/pasted the file into the same folder where it's stored, then double-clicked the copy and it opens fine.
    5. Closed the copy, tried to open the original, still get file not found / error 1502.
    The file does exist, it IS there.. sometimes the user just copies it to their local desktop (well, it's not really local, it's redirected) and it opens fine there.. other users email themselves a copy of the file and then open it that way.. it works for
    some, not for others.. and there's no discernible pattern yet to identify who this is affecting. Anyone have any ideas?
    -Keith
    -Keith Elkin

    Hi,
    Based on the error message, the issue may be caused by the Visio file is occupied by some other program in DFS.
    >>4. Copy/pasted the file into the same folder where it's stored, then double-clicked the copy and it opens fine.<< If you did this step, the Visio file would rename in the same folder, like file1.vsd. Thus, it opened well.
    Thus, I recommend you check the file's status in computer management in DFS server, see the below image:
    If the affected Visio files were occupied, please try to clean them(right click>close the file) to test.
    Hope it's helpful.
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.
    Sorry,
    This didn't help, the files are not open, locked open, and the issue still persists. Any other suggestions?
    -Keith
    -Keith Elkin

  • Is there a way to switch off by default the video on FaceTime? I only ever use this app for audio/calls and hate the video being on. I especially hate that if I leave the app open to receive calls it means the camera and green light are on.

    My issue is that I can't find a way to have the camera switched off when the app is open and so this means if I want the app open all day to receive calls then the camera is going to be on the whole time. Even if it didn't potentially drain the battery, or add to the CPU usage or whatever else may cause any problems whatsoever (wheel of death!), I just don't want the camera on as I don't see myself ever wanting to use the video call feature but I would use the audio/call multiple times throughout the day to make and receive calls. The camera being on when the app is open is enough to prevent me from using the app. Also ever since seeing that episode of criminal minds where if you saw the green light on above the screen then it meant the killer was watching you!
    Basically I just can't believe there isn't a way to disable the camera whilst having the app running. I know when initiating an audio call the camera goes away, but I would like the camera away the whole time. To me it just would make sense that if you click the video option then the camera is on, and if you click the audio option then the camera goes off. It just seems waaaaay to basic a thought for apple to have missed... Let's face it, we're not all as pretty as the people in the apple adverts and don't want to see our ugly mugs staring back as us when we work all day at our macs!

    I have exactly the same concern. It seems it would be a simple fix for Apple to allow users to turn off the camera (and even the mic) while keeping FaceTime open -- especially now that it turns out FaceTime must remain open in order to send and receive iPhone calls on a Mac.
    I like to think this new functionality of FaceTime will be baked into a future release of Yosemite, as the current setup has that not-quite-finished feel of a work in progress. In the meantime, there's nothing like a little piece of Post-It stuck over the camera to keep the NSA from watching your face as you type a post to the Apple Support Communities.

  • I have a two page letter. I want the first page to have my company letter head, but want the second page to start up at the top of the page without the letter head (just text) how do i do that? I also upgraded to the new Pages. Thank You

    Hello!
    I have a two page letter that I am putting together for my company.
    I need the logo on the first page, but the next page(s) i do not want the logo and i do not want the indentation.
    can someone help me solve this problem. Know it must be  a quick fix
    I also have the new version of Pages installed as well.

    In Word, all you should have to do (with the document open, of course), is choose Insert > Page Numbers… . Choose how you want them to appear and click OK.
    Make sure to save the file to retain the page number addition.

  • I like the feature of the PDF being opened on the new tab on firefox browser windows. But the newer version (3.6 or 4.0) will automatically open PDF in a pop up adobe apps. How do I keep the PDF open on the new tab as before? thank you

    I like the feature of the PDF being opened on the new tab on firefox browser's windows. But the newer version (3.6 or 4.0) will automatically open PDF in a pop up adobe apps. How do I keep the PDF open on the new tab as before like the 3.5 ver.? I want the PDF opened in the new tab rather than in the Adobe's app's pop up window. Could you help?
    thank you

    '''I fixed mine by removing the Ask.com extension.'''
    Tools
    Add-ons
    Settings icon
    View Recent Updates
    Ask.com '''DISABLE'''
    Running FF 8.0 on Windows 7 (64-bit)

  • Photoshop Open dialog does not show all files

    I've been noticing that unconsitantly the Photoshop Open dialog does not show all PSD files in a folder, some are just plain missing. In Finder they show up like normal though. Anyone else with this problem?

    The open and save dialogs are provided and mostly run by the OS, not the application.
    It sounds like you might have a filter set on your open dialog (like the search option).

  • When opening a pinned program from the taskbar the programs opens in a new icon in the taskbar.

    Hey
    In some special occasions, I have the problem that when you press an pinned icon the program is not "grouped" with the pinned icon, but opens in a new icon, please see this image to better understand:
    http://misc.norphf.dk/PinnedIcon.bmp
    As you can see in the picture, the properties of both icons are alike
    In this case I have manually changed the icon to add the "4twhpv3 dl", but I also have the problem with e.g. Active Directory Users and Computers 32BIT path "%windir%\SysWOW64\dsa.msc" it works with the normal ADUC started form "control panel" (I use the 32
    bit version to get an extension to work).
    Can someone help with this?
    Regards Lars Mortensen

    Doesn’t affect functionality?! - It sure does, with my Active Directory Users and Computers, which I have lying on win+7 every time I press win+7 it opens a
    new window instead of using the currently opened, that’s not very functional....
    But found a solution myself
    If I create a shortcut, and changes this shortcut, places that shortcut on a local disk (Network locations/mapped drives doesn't work) then I can right click that
    shortcut and "Pin to taskbar", then the program opens in the same icon and does not create a new.
    Hopes this is understandable.

Maybe you are looking for

  • GTX Titan in After Effects & Premiere CS6

    GTX Titan Superclocked now running in OS X 10.8.3 using the latest NVIDIA Web Driver (313.01.01f03) and CUDA Driver Version 5.0.59. I've modified both the "cuda_supported_cards.txt" file for Premiere Pro CS6 (6.0.2) and the "raytracer_supported_cards

  • Unable to play wmv files in authorware

    Hi, I am trying to use a digital movie icon to play a wmv file. The file plays fine on my computer and I have also tested it on other computers. When I place the file in Authorware, I see a black image where the movie should be. Neither the movie or

  • Oracle BI with Oracle Financials

    How easy is it to prepare the Oracle database to allow Oracle BI to integrate with Oracle Financials? To expand, our organization is currently using Oracle Financials and we are considering implementing Oracle BI to support reporting. Is this fairly

  • XI scenarios

    What kind of scenarios we will do in real time? give me with example. points will be awarded. thanks in advance.

  • Portal asking for Login details again while executing the reports

    Hi Team, Our Portal is asking for Login details again while executing the reports individually. The issue is the if i enter the same PORTAL Login credentials, its showing as Authentication failed. PLEASE ADVICE ASAP. thanks & regards Sneha