read

Error “This stream does not support seek operations” in C#

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to get an image from an url using a byte stream. But i get this error message: This stream does not support seek operations. This is my code: byte[] b; HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url); WebResponse myResp = myReq.GetResponse(); Stream stream = myResp.GetResponseStream(); int i; using (BinaryReader br = new BinaryReader(stream)) { i = (int)(stream.Length); b = br.ReadBytes(i); // (500000); } myResp.Close(); return b; What am i doing wrong guys? 回答1: You probably want something like this. Either checking

Gson: Expected a string but was BEGIN_OBJECT

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to read a simple JSON response. { "response": "ok" } Here is my code: JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8")); String response = null; boolean success = false; reader.beginObject(); if (reader.hasNext()) { String token = reader.nextName(); if (token.equals("response")) { response = reader.nextString(); } else { reader.skipValue(); } } reader.endObject(); reader.close(); But I am getting this error: Expected a string but was BEGIN_OBJECT I don't understand what I am doing wrong. Can you help me? 回答1:

imageio.IIOException: Can't read input file

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've started Java a week ago, and now I would like to insert an image into my window. Whatever I try I keep having this in Eclipse: javax.imageio.IIOException: Can't read input file! package graphics; import java.awt.Color; import java.awt.Graphics; import java.awt.Image; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JPanel; import src.Common; public class Window extends JFrame { public class Panel extends JPanel { public void paintComponent(Graphics g) { Image

What is the effective NFC read bitrate using APDU commands?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am currently sending and receiving an accumulated 1628 bytes using the Android IsoDep.trancieve() function spread over 35 APDU commands (select application, authenticate, read). The bytecount includes returned MAC checksums and result codes as returned by transcieve(). This communication takes 580ms. As these bytes are sent and received half duplex i calculate the effective bitrate to ~220kbit/s. The Android NFC stack supports 424kbit/s NFC communication, and according to This Wikipedia article uses 10% modulation (=protocol overhead?) Do

pySerial buffer won't flush

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm having a problem with serial IO under both Windows and Linux using pySerial. With this code the device never receives the command and the read times out: import serial ser = serial.Serial('/dev/ttyUSB0',9600,timeout=5) ser.write("get") ser.flush() print ser.read() This code times out the first time through, but subsequent iterations succeed: import serial ser = serial.Serial('/dev/ttyUSB0',9600,timeout=5) while True: ser.write("get") ser.flush() print ser.read() Can anyone tell what's going on? I tried to add a call to sync() but it

How do I read cx_Oracle.LOB data in Python?

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this code: dsn = cx_Oracle.makedsn(hostname, port, sid) orcl = cx_Oracle.connect(username + '/' + password + '@' + dsn) curs = orcl.cursor() sql = "select TEMPLATE from my_table where id ='6'" curs.execute(sql) rows = curs.fetchall() print rows template = rows[0][0] orcl.close() print template.read() When I do print rows , I get this: [(<cx_Oracle.LOB object at 0x0000000001D49990>,)] However, when I do print template.read() , I get this error: cx_Oracle.DatabaseError: Invalid handle! Do how do I get and read this data? Thanks. 回答1: I

Howto read Excel file in Scala [closed]

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a way to read an Excel file in Scala (xls not csv)? I mean are there any Scala libraries to do so? 回答1: Try Apache POI , it's a Java library for reading most of Microsoft's document formats. 文章来源: Howto read Excel file in Scala [closed]

programmatically READ iPhone settings

匿名 (未验证) 提交于 2019-12-03 02:42:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to programmatically READ iPhone settings such as... Enable 3G - YES/NO Vibrate - ON/OFF Message Alert - ON/OFF etc. Can anyone provide a solution? 回答1: I'm fairly certain you cannot: see Opening the Settings app from another app 回答2: You cannot. Because apple is not providing the API to access the iPhone settings app. But you can keep a bundle setting in your app so that user can change the settings of your app from iphone settings. If you are interested in this feature you can refer Apple doc. 文章来源: programmatically READ iPhone

&#039;\\r&#039;: command not found [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: '\r': command not found - .bashrc / .bash_profile 16 answers echo "Select your option:" echo "1. Change ip address" echo "2. Add route" echo "3. Reboot" echo "4. Exit" read A case $A in 1) echo "Add Ip address" read IP echo "Add Netmask" read Netid echo "Add name of interface" read Interface ifconfig ${Interface} ${IP}/${Netid} if [ $? -ne 0 ];then echo "Ip address not configured" fi ;; 2) echo "Add Destination" read dst echo "Add Netmask" read Netid echo "Add Gateway" read gw route add $dst mask

Is it possible to read pdf/audio/video files(unstructured data) using Apache Spark?

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it possible to read pdf/audio/video files(unstructured data) using Apache Spark? For example, I have thousands of pdf invoices and I want to read data from those and perform some analytics on that. What steps must I do to process unstructured data? 回答1: Yes, it is. Use sparkContext.binaryFiles to load files in binary format and then use map to map value to some other format - for example, parse binary with Apache Tika or Apache POI. Pseudocode: val rawFile = sparkContext.binaryFiles(... val ready = rawFile.map ( here parsing with other