Cant read the transfered file
i transfer the jpg file but it shows no previwe available
and the transfered file is always 8kb short
//package ksm.mulitiserver;
import java.io.*;
import java.net.*;
import java.sql.*;
public class MultiServer
private ServerSocket Server;
private Socket Client;
private int ConnectionCounter;
private int Port;
public MultiServer()
ConnectionCounter=0;
Port=5000;
Init();
public void Init()
try
Server=new ServerSocket(4444);
while(true)
WaitingForConnection();
CreateThread();
catch(Exception e)
System.out.println(e);
public void CreateThread()
try
System.out.println("Total Active Users:\t"+ConnectionCounter);
ConnectionCounter++;
new ServerThread(Client,ConnectionCounter);
catch(Exception e)
System.out.println(e);
return;
public void WaitingForConnection()
System.out.println("Waiting For Connection "+Server.getInetAddress().getHostName());
System.out.println("Listening on port: "+Server.getLocalPort());
try
do
Client=Server.accept();
while(Client==null);
System.out.println("Client Found:\t"+Client.getInetAddress().getHostName());
catch(Exception e)
System.out.println(e);
public static void main(String a[])
new MultiServer();
// client
//package ksm.mulitiserver;
import java.io.*;
import java.net.*;
public class Client
{ String s;
public int Client(String s1)
{ s=s1;
Processing();
return 0;
public void Processing()
try
Socket client=new Socket("localhost",4444);
BufferedReader br;
BufferedWriter bw;
String strmsg;
br=new BufferedReader(new InputStreamReader(client.getInputStream()));
bw=new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
System.out.println("Connected to "+client.getInetAddress().getHostName());
String strinput=null;
String strrecv=null;
bw.write(s+"\n");
bw.flush();
strrecv=s.substring(0,1);
if(s.equals("u"))
FileInputStream fis=new FileInputStream("e:/mah.jpg");
OutputStream out = client.getOutputStream();
byte[] buffer = new byte[10];
int bytesRead;
while ((bytesRead = fis.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
out.flush(); // Very important
fis.close(); // Also very important
else
{ FileOutputStream fos=new FileOutputStream("c:/nextcalltoclient.jpg");
InputStream in = client.getInputStream();
byte[] buffer = new byte[100];
int bytesRead;
while ((bytesRead = in.read(buffer)) > 0)
fos.write(buffer, 0, bytesRead);
fos.flush(); // Very important
fos.close(); // Also very important
bw.close();
br.close();
//client.close();
catch(Exception e)
System.out.println(e);
public static void main(String a[])
{ Client c=new Client();
int c1=c.Client("u");
c1=c.Client("d");
// serverthread
//package ksm.mulitiserver;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.lang.*;
public class ServerThread extends Thread
public Socket Client;
public int ID;
public ServerThread()
public ServerThread(Socket stemp,int id)
try
Client=stemp;
ID=id;
catch(Exception e)
System.out.println(e);
this.start();
public void run()
Processing();
public void Processing()
try
BufferedReader br;
BufferedWriter bw;
//String strmsg;
br=new BufferedReader(new InputStreamReader(Client.getInputStream()));
bw=new BufferedWriter(new OutputStreamWriter(Client.getOutputStream()));
String strquerytext=new String();
String strresult=new String();
strresult=br.readLine();
if(strresult.equals("u"))
FileOutputStream fos=new FileOutputStream("g:/firstcalltoclient.jpg");
InputStream in = Client.getInputStream();
byte[] buffer = new byte[10];
int bytesRead;
while ((bytesRead = in.read(buffer)) > 0)
fos.write(buffer, 0, bytesRead);
fos.flush(); // Very important
fos.close(); // Also very important
System.out.println("file uplaod finish");
else
{ FileInputStream fis=new FileInputStream("g:/mah.jpg");
OutputStream out = Client.getOutputStream();
byte[] buffer = new byte[100];
int bytesRead;
while ((bytesRead = fis.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
out.flush(); // Very important
fis.close(); // Also very important
System.out.println("file download finish");
//new code ends here
br.close();
bw.close();
System.out.println("Client:\t"+Client.getInetAddress().getHostName()+" terminated");
Client.close();
catch(Exception e)
System.out.println(e);
what is wrong with code???
i also tried varying the buffer size.
1. It appears your client and server code are mixed. They should be entirely seperate.
2. You can't use a text reader on binary input.
3. Don't mix binary and text data without differentiating them.
4. Now you are sending data and only data via the socket. You should be sending a message. That message contains data like a name and binary data.
I would guess the reason you are seeing a difference is because you are wrapping the stream in a text reader. The text reader reads a block, which moves the stream position. When you start reading the stream directly the position is way past where the single line that you think you are reading is.
Similar Messages
-
hi im having huge problems trying to install flash for my mac 10.5 imac, iv gone through the internet and tried all of the solutions, everytime i try to install flash it says cant read the download file, or it just wont install, anybody plz help!
iv unistalled flash, iv checked plug ins it just wont work,It would have been a great help to know precisely what Mac you have, so some of the following may not apply:
You can check here: http://www.adobe.com/products/flash/about/ to see which version you should install for your Mac and OS. Note that version 10,1,102,64 is the last version available to PPC Mac users*. The latest version,10.3.183.23 or later, is for Intel Macs only running Tiger or Leopard, as Adobe no longer support the PPC platform. Version 11.4.402.265 or later is for Snow Leopard onwards.
(If you are running Mavericks: After years of fighting malware and exploits facilitated through Adobe's Flash Player, the company is taking advantage of Apple's new App Sandbox feature to restrict malicious code from running outside of Safari in OS X Mavericks.)
* Unhelpfully, if you want the last version for PPC (G4 or G5) Macs, you need to go here: http://kb2.adobe.com/cps/142/tn_14266.html and scroll down to 'Archived Versions/Older Archives'. Flash Player 10.1.102.64 is the one you download. More information here: http://kb2.adobe.com/cps/838/cpsid_83808.html
You should first uninstall any previous version of Flash Player, using the uninstaller from here (make sure you use the correct one!):
http://kb2.adobe.com/cps/909/cpsid_90906.html
and also that you follow the instructions closely, such as closing ALL applications (including Safari) first before installing. You must also carry out a permission repair after installing anything from Adobe.
After installing, reboot your Mac and relaunch Safari, then in Safari Preferences/Security enable ‘Allow Plugins’. If you are running 10.6.8 or later:
When you have installed the latest version of Flash, relaunch Safari and test.
If you're getting a "blocked plug-in" error, then in System Preferences… ▹ Flash Player ▹ Advanced
click Check Now. Quit and relaunch your browser.
You can also try these illustrated instructions from C F McBlob to perform a full "clean install", which will resolve the "Blocked Plug-in" message when trying to update via the GUI updater from Adobe.
Use the FULL installer for 12.0.0.44: Flash Player 12 (Mac OS X)
And the instructons are here: Snow Leopard Clean Install.pdf
(If you are running a PPC Mac with Flash Player 10.1.102.64 and are having problems with watching videos on FaceBook or other sites, try the following solution which fools the site into thinking that you are running the version 11.5.502.55:)
Download this http://scriptogr.am/nordkril/post/adobe-flash-11.5-for-powerpc to your desktop, unzip it, and replace the current Flash Player plug-in which is in your main/Library/Internet Plug-Ins folder, (not the user Library). Save the old one just in case this one doesn't work. -
Photoshop Elements 11 cant read the raw files from my Fuji x-e2, what can i do?
I need help please as I cant work on the raw file from my Fuji x-e2 on Photoshop Elements 11 as it cant read them. any suggestions what I can do?
Unfortunatly it seems that the camera raw 8.3 plugin is required, which is still in a public beta for photoshop, but even
when it's released as final, pse 11 will most likely not be able to use it.
You could however download the
DNG Converter 8.3 Release Candidate
and convert your Fuji X-E2 files to dng copies which should then open in pse 11
http://labs.adobe.com/downloads/cameraraw8-3.html -
when i plug my ipod into the computer it says in itunes that it cant read the contents of my ipodtouch and i would have 2 restore it. i dont really get what this means? and i dont want 2 restore it because i dont want 2 lose everything in my ipod. i dont know if it has anything 2 do with the fact that my ipod is running out of space? also my computer hard drive broke so we had 2 get a new one, therefore everything was deleted ,yet when i downloaded itunes again for the first time and pluged my ipod in it didnt give me that message that it couldnt read the contents. so i dont know whats going on? if u could help that would be great !
you can transfer iTunes purchases to the computer by:
iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
One of the third-party programs dicussed here will transfer other stuff:
new PC: Apple Support Communities
If you are in the USA and using the latest iTunes you can redownload music via the iCloud beta. See:
Downloading past purchases from the App Store, iBookstore, and iTunes Store -
Forefox won't start in windows XP: I get the message that windows "cant' find the exe file" even when I click from the program file, rather than the shortcut.
Delete the current Firefox shortcut on the desktop and create a new desktop shortcut via the right-click context menu on the Firefox.exe program (Send to > Desktop)
-
Hi All,
powershell script Method required to read a value from registry and then taking the backup of that values in some text file.
For example the hive is
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path
and under path i need to take back up of values in some text file and then put some value in the registry after back is taken in text file.
Also how to read the text file values so that we can again write to registry hive back from the back up text file.
Your help is much appreciated.
Umeed4uI think you need to read this first:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/a0def745-4831-4de0-a040-63b63e7be7ae/posting-guidelines?forum=ITCG
Don't retire TechNet! -
(Don't give up yet - 12,830+ strong and growing) -
I have the latest downloadable version of LR5. It crashed while it was createing 1:1 previews during an import. After a Win7(64) restart, it shows a message that LR needs to quit because it can't read the preview files and it will try to fix it the next time is launches. I get the same message the next and every subsequent time it launches so I can't launch LR at all now.
I get that the preview file got corrupted somehow. Is there some way to fix this problem without building a new catalog?Use Windows Explorer to open the folder containing your catalog. You will see a folder with the extension .lrdata. You need to delete that folder and then start Lightroom again. Lightroom will generate a new previews folder.
-
Not able to read the wsdl file from server Premature EOF encounter
Hi All,
I am facing issue while accessing a web Service from server. Here is the clear view about it.
I created a simple SyncBpel process in a composite and deployed in to the server and it is working fine. Later i created a new Asyn bpel process in a composite and in the external reference i dragged a web Service and imported the wsdl url from server of the SyncBpel and wired the Asynbpel process to webserive .
Now here i am facing peculiar behavior which i am not able to trace it out.
1) For the first time when i import the url of syncBpel from the server i am not facing any error and it is working fine as expected but when i close the Jdeveloper and open it i am not able to user the web Service and it is saying as "Not able to read the wsdl file from server Premature EOF encounter"
2)When i close and open the Jdeveloper i can see the url of the wsdl which imported in webserver is changing from http://stcfmw03.satyam.com:8021/soa-infra/services/Tarak/synchronousBpel/bpelsync_client_ep?WSDL to http://stcfmw03.satyam.com:8021/soa-infra/services/Tarak/synchronousBpel/BPELsync.wsdl
3)when I open and see the url http://stcfmw03.satyam.com:8021/soa-infra/services/Tarak/synchronousBpel/bpelsync_client_ep?WSDL I can see the soap address as *<soap:address location="http://stcfmw03.satyam.com:8021/soa-infra/services/Tarak/synchronousBpel!1.0*soa_5cfb8416-c106-40a2-a53b-9054bbe04b9c/bpelsync_client_ep"/>*
I don’t understand why the soap end contains “*soa_5cfb8416-c106-40a2-a53b-9054bbe04b9c” and this kind of url for soap address is coming to all the bpel process which I am deploying in the server.
I checked the in Jdeveloper where webproxy is uncheck and the server is also up but still I am facing issue of reading the error.
Can someone please help in resolving the issue.
I am using SOA 11g 11.1.1.5 and Jdeveloper 11.1.1.5
Many thanks.
Tarak
Edited by: user11896572 on Jan 17, 2012 5:22 PMHi,
Setting default from the jdeveloper -
During composite deployment from Jdeveloper (wizard driven), you will be given an option to choose the version of the composite and there will also be an option for you to choose if the composite needs to be deployed as default.
Setting default from the em console -
After deploying a composite, login to the em console and click on the composite that you want to set as default, and you will find a tab - "Set as Default". please note that this tab will not be seen, if the composite is already set as default.
Refer -
http://docs.oracle.com/cd/E12839_01/integration.1111/e10226/soacompapp_mang.htm
8.2 Managing the State of Deployed SOA Composite Applications
Thanks -
In Vista, Applet isn�t able to read the property files
I�m working on internationalization; the Applet which I�m using wasn�t able to read the property files properly in windows Vista machine. But if I create a jar which contains all the classes and property files, Applet works fine.
This problem is only in Vista machine ,In XP the JVM is smart enough to read plain .property files and its works well without creating the jar
Is that related to any security enhancemence of vista over XP?
Below is a link about The Java Security Model break on Windows Vista
http://bugs.sun.com/view_bug.do?bug_id=6548078
I tried a simple ResourceBundle.getBundle() in my Applet in different ways but nothing work fine for me. It isn�t an issue related to path, I guess because I tried several ways like.
ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle");
ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle",currentLocale);
ResourceBundle labels = ResourceBundle.getBundle("com.test.LabelsBundle");
ResourceBundle labels = ResourceBundle.getBundle("com.test.LabelsBundle",currentLocale);The exception got in java console is
CONFIG: [2008-05-13 15:54:57.909]:(com.satm.insite.InsiteApplet$2@1696e4c):InisiteApplet: Exception: java.util.MissingResourceException: Can't find bundle for base name LabelsBundle, locale en
java.util.MissingResourceException: Can't find bundle for base name LabelsBundle, locale en
at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at com.satm.insite.InsiteApplet.displayValue(InsiteApplet.java:261)
at com.satm.insite.InsiteApplet.callme(InsiteApplet.java:296)
at com.satm.insite.InsiteApplet.initialize(InsiteApplet.java:327)
at com.satm.insite.InsiteApplet$2.run(InsiteApplet.java:235)
at com.satm.tools.languageTools.ThreadPool$ExceptionCatchingThread.run(ThreadPool.java:226)Is there any way to make it work in Windows Vista machine�? This could be a great help for me.
Thanks
RobertCrossposted:
http://forum.java.sun.com/thread.jspa?threadID=5295743&messageID=10250558#10250558
http://forum.java.sun.com/thread.jspa?threadID=5295742&messageID=10250556#10250556 -
How can I read the bootstrap files of any HDS Live stream and extract the fragment-URLs and fragment-numbers in plain text?
Could it be that it is some kind of compressed format in the bootstrap? Can I uncompress it wirh f4fpackager.exe? Could not find any download for f4fpackager.exe. I would prefere less code to do so. Is there something in Java of JavaScript, that can extract the fragment-numbers?
Thank you!Doesn't sound too hard to me. Your class User (the convention says to capitalize class names) will have an ArrayList or Vector in it to represent the queue, and a method to store a Packet object into the List. An array or ArrayList or Vector will hold the 10 user objects. You will find the right user object from packet.user_id and call the method.
Please try to write some code yourself. You won't learn anything from having someone else write it for you. Look at sample code using ArrayList and Vector, there's plenty out there. Post in the forum again if your code turns out not to behave. -
"Error: Final Cut Pro was unable to read the movie file just captured"
Hello everyone!
We had a computer crash while we were working on Final Cut Pro and backing up some media to a hard drive.
Since then, whenever we "capture' video footage and hit the escape key to stop capturing - we get -
"Error: Final Cut Pro was unable to read the movie file just captured"
We reinstalled the Final Cut Pro software all over again thinking that maybe the software got corrupted and we also rectified any disk permissions for the hard drives.
Any ideas?
Thanks
Efrain
G 5 Mac OS X (10.4.8)We had a computer crash while we were working on Final Cut Pro and backing up some media to a hard drive.< </div>
You eventually want to figure out how that happened and make sure you fix it.
Since then, whenever we "capture' video footage and hit the escape key to stop capturing - we get -
"Error: Final Cut Pro was unable to read the movie file just captured"
<
You reformatted the external drive, yes? You might not have used the correct initialization setting. Should be Macintosh HFS, journalling is optional. Or you have a drive formatted for Winderz.
Aside from incorrect drive formatting, we have seen this error if the capture is incomplete or improperly terminated.
It's not an FCP issue, it's hardware.
bogiesan -
Is there any way to read the pdf file in java
Hai,
i need some advice from anyone that is there anyway to read the pdf file directly from java...
Without converting to other files(txt,html)
if it is possible please help me..
Thank youOr use the Adobe one (search the adobe site). Or search this forum, this is one of the Top Ten Qestions Asked here.
-
Please help me in reading the ascii file in encoded format
hi ,
iam trying to read the ascii file and i need to encode the text file, can u suggest me what arre the different methods are availble for me to encode the text file, please suggest me which is the effiecient method tto use?This question has been answered before, please search the forums in future.
You could do something like this, it probably not the most efficient though.
If you don't need to do it in code then the native2ascii does this conversion see: http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/native2ascii.html
public static void convert(String vsFile) throws IOException
File f = new File(vsFile);
FileReader fr = new FileReader(f);
char[] buf;
int bytesRead = 0;
int startAt = 0;
String content = "";
do
buf = new char[512];
bytesRead = fr.read(buf, 0, 512);
startAt += bytesRead;
String tmp = new String(buf);
content += tmp;
while (bytesRead == 512);
FileOutputStream fout = new FileOutputStream(f);
OutputStreamWriter out = new OutputStreamWriter(fout, "UTF-8");
out.write(content.trim());
out.flush();
out.close();
} -
Problem in reading the excel file path in WINDOWs machine from UNIX environ
Hello friends,
My requirement is to read each row of the excel sheet and sent that row to the database. I have implemented it by using jxl and apache poi framework. locally in my WINDOWS machine it is working fine..
But when i deploy the code in UNIX machine. My application runs on a Unix server , trying to read the excel file in WINDOWS environment. I am not able to retrieve the file path. for ex : C:\Documents and Settings\sabbanik\My Documents\KARUNAKAR\excel.xls
I am getting error in this line
workbook = Workbook.getWorkbook(filepath)
Error message : input file not found.
Thanks in advance..You said: I am getting error in this line workbook = Workbook.getWorkbook(filepath) >
Based on this, I will assume you are trying to use OLE to access information about the Excel file. As mentioned by Andreas, your code will be executing on the server (Unix) and since Excel isn't on the server (and cannot be) an error will result. OLE can only be used in Windows environments (client or server). To access client side OLE calls and content, you need a java bean and Excel installed on the client machine. Oracle provides WebUtil as an option to writing your own Java Bean. To use this, you will need to be running Forms 10.1.2 or newer. Details can be found here along with a demo:
http://www.oracle.com/technetwork/developer-tools/forms/webutil-090641.htm -
Reading the xml file in customized table.
Hi Experts ,
I have a requirement to read the xml file in one "z" table . Can anyone let me know the exact steps .
Thank you
AshutoshHi Ashutosh,
1. First read the file in BINARY MODE into an XSTRING.
2. Then use the method create_istream_xstring to create the input stream
3. Then you need to create the document tree and the parser
4. Once your Document tree and your parser are created now can use the document tree to access individual elements.
Some Class interfaces that maybe helpful to you are as follows: if_ixml_node, if_ixml_node_iterator, if_ixml_element....etc
DATA:o_ixml TYPE REF TO if_ixml,
o_streamfactory TYPE REF TO if_ixml_stream_factory,
o_istream TYPE REF TO if_ixml_istream.
o_parser TYPE REF TO if_ixml_parser
o_document TYPE REF TO if_ixml_document
o_ixml = cl_ixml=>create( ).
o_istream = o_streamfactory->create_istream_xstring( string = <give the xstring name here>).
o_document = o_ixml->create_document( ).
o_parser = o_ixml->create_parser( stream_factory = o_streamfactory
istream = o_istream
document = o_document ).
You can make the final code as dynamic as possible to read into an internal table.
Regards
-Joe
Maybe you are looking for
-
HP LaserJet 1018 and Windows 8.1
Hello, I was trying to select the "Print directly to the Printer" option under my 1018's printer properties, but I keep getting the following: "Printer Properties Printer settings could not be saved The specified datatype is invalid" Can anyone instr
-
ITunes does not open in Windows 7
I am running Windows 7 64 bit Professional on a new HP workstation. Have transferred everything, including user accounts, music libraries and iTunes from an older HP PC (motherboard died!). For several days iTunes opened with no problem, but has now
-
Problematic issues in installing backup domain controller on Virtual Machine
Hello,<o:p></o:p> I have a physical domain controller - windows Server 2012 R2 Standard installed in my domain environment and this is a first root domain controller. I have also Hyper-V Server 2012 R2 installed and joined in that domain. Now I want
-
How can I get back deleted files to my iPod?
First of all, I tried to upgrade my iPod's iOS 4.2.1 to 5. I followed the steps in the following page: http://support.apple.com/kb/ht4972. Unfortunately, I unsucceeded as the iOS stayed the same but I lost all of my downloaded music and video files.
-
Pagemaker 7.0 to InDesign CS2
I have several PageMaker 7.0 files that I want to open/convert to InDesign but when I try and open them in InDesign I get an error message: The PageMaker document is damaged and cannot be recovered. It opens in PageMaker just fine so I renamed it and