Some Java sample code

Ξ February 19th, 2008 | → 0 Comments | ∇ Programs |

ObjectInputStream inputstream = new ObjectInputStream(fis);int numAvailable = inputstream.available();theBean = (TempBean)inputstream.readObject();for(int i = 0; i <= numAvailable; i++ ){
public class ObjectInputOutput implements PlayerInterface {
static ObjectInputStream inputStream = null;
static ObjectOutputStream outputStream = null;
static FileInputStream fis = null;
static FileOutputStream fos = null;
public Collection<PlayerBean> readStuff(String file) {
Collection<PlayerBean> aCollection = new ArrayList<PlayerBean>();
try {
fis = new FileInputStream(file);
inputStream = new ObjectInputStream(fis);
int num = fis.available();
PlayerBean aBean = new PlayerBean();
for (int i = 0; i <= num; i++) {
aBean = (PlayerBean) inputStream.readObject();
aCollection.add(aBean);
}
try {
}
catch (Exception e) {
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
return aCollection;
}
public void writeStuff(Collection aCollection, String file) {
try {
fos = new FileOutputStream(file);
outputStream = new ObjectOutputStream(fos);
Iterator iterator = aCollection.iterator();
while (iterator.hasNext()) {
Object someBean = iterator.next();
PlayerBean testBean = (PlayerBean) someBean;
outputStream.writeObject(testBean);
}
outputStream.writeObject(file);
}
catch (Exception e) {
}
finally {
if (outputStream != null) {
try {
outputStream.flush();
outputStream.close();
}
catch (IOException e) {
}
}
}
}
}

Original post by Extreme

 

Mouse speed in Linux

Ξ June 11th, 2007 | → 0 Comments | ∇ Programs |

do: xset m 1/4 10 // 1/4 = speed 1/2 or 3 up to like 7
in this fodler: /usr/X11R6/bin
Worked for me, we'll see if it stick after reboot.

Original post by Extreme

 

Canon EOS Rebel XTi (400D) with Digikam

Ξ June 7th, 2007 | → 0 Comments | ∇ Programs |

Problem: Canon EOS 400D / Rebel XTI is not supported after install.
Resolution:
Open a terminal and redirect output to a text file:
for dev in `ls /sys/bus/usb/devices`; do udevinfo -ap /sys/bus/usb/devices/$dev; done > /home/yourusername/udevinfo.txt
Open the udevinfo.txt and search for canon
It will look like this:
looking at device '/devices/pci0000:00/0000:00:1d.7/usb5/5-5':
ID=="5-5"
BUS=="usb"
DRIVER=="usb"
SYSFS{configuration}==""
SYSFS{product}=="Canon Digital Camera"
SYSFS{manufacturer}=="Canon Inc."
SYSFS{maxchild}=="0"
SYSFS{version}==" 2.00"
SYSFS{devnum}=="7"
SYSFS{speed}=="480"
SYSFS{bMaxPacketSize0}=="64"
SYSFS{bNumConfigurations}=="1"
SYSFS{bDeviceProtocol}=="00"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bDeviceClass}=="00"
SYSFS{bcdDevice}=="0002"
SYSFS{idProduct}=="3110" <——–
SYSFS{idVendor}=="04a9" <——–
SYSFS{bMaxPower}==" 2mA"
SYSFS{bmAttributes}=="c0"
SYSFS{bConfigurationValue}=="1"
SYSFS{bNumInterfaces}==" 1"
Open /etc/udev/rules.d/45-libgphoto2.rules
sudo nano -w /etc/udev/rules.d/45-libgphoto2.rules
Add the following lines at the bottom of the file, just before LABEL="libgphoto2_rules_end"
SYSFS{idVendor}=="YOURIDVENDOR", SYSFS{idProduct}=="YOURIDPRODUCT", MODE="0660", GROUP="plugdev"
For me it was:
SYSFS{idVendor}=="04a9", SYSFS{idProduct}=="3110", MODE="0660", GROUP="plugdev"
Restart udev
Code:
sudo /etc/init.d/udev restart
via: http://ubuntuforums.org/showthread.php? … hlight=xti
i got sick of searching for it over and over again.

Original post by Extreme

 

  • Rumours and Lies