Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Tim Cooke
Paul Clapham
Liutauras Vilda
Sheriffs:
Junilu Lacar
Rob Spoor
Jeanne Boyarsky
Saloon Keepers:
Stephan van Hulst
Carey Brown
Tim Holloway
Piet Souris
Bartenders:
Forum:
Android
Reading a file
Mike Brooks
Greenhorn
Posts: 14
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hey,
I have put a file on an sdcard and I am right now trying to read it to send using sockets. My code is
File myFile = new File ("/sdcard/psi2.pdf"); byte[] mybytearray = new byte[(int)myFile.length()]; FileInputStream fis = new FileInputStream(myFile); BufferedInputStream bis = new BufferedInputStream(fis); bis.read(mybytearray,0,mybytearray.length); OutputStream os = client.getOutputStream(); System.out.println("S: Sending file"); os.write(mybytearray,0,mybytearray.length); os.flush();
The error comes from this line
FileInputStream fis = new FileInputStream(myFile);
Monu Tripathi
Rancher
Posts: 1369
1
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It would help if you can specify the exact error that you are getting.
[
List of FAQs
] | [
Android FAQ
] | [
Samuh Varta
]
Mike Brooks
Greenhorn
Posts: 14
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The error is
E/TCP ( 716): java.lang.NumberFormatException: unable to parse '%PDF-1.4' as integer E/TCP ( 716): at java.lang.Integer.parse(Integer.java:385) E/TCP ( 716): at java.lang.Integer.parseInt(Integer.java:374) E/TCP ( 716): at java.lang.Integer.parseInt(Integer.java:333) E/TCP ( 716): at com.budasmj.TCPClient.run(TCPClient.java:40) E/TCP ( 716): at java.lang.Thread.run(Thread.java:1058) D/TCP ( 716): S: Done.
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Read a music file
Transferring file name then file data over socket
Socket connection program works for localhost but not for other ip
Transfer multiple files from Server to Client using Sockets
copying files over a network
More...