///
/// read the file line by line
///
try {
BufferedReader in = new BufferedReader(new FileReader(args[0]));
String str;
while ((str = in.readLine()) != null) {
_log(str);
}
in.close();
} catch (IOException e) {
}
martes, junio 14, 2011
Read a text file line by line in Java
jueves, junio 09, 2011
Write a text file in Android using the emulator in Eclipse
///
/// check read/write permissions
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
mExternalStorageAvailable = mExternalStorageWriteable = true;
Log.i(TAG,"read + write");
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
// We can only read the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
Log.i(TAG,"read");
} else {
// Something else is wrong. It may be one of many other states, but all we need
// to know is we can neither read nor write
mExternalStorageAvailable = mExternalStorageWriteable = false;
Log.i(TAG,"nothing");
}
///
/// write text file
File testFile = new File(Environment.getExternalStorageDirectory()+"/test.txt");
try{
testFile.createNewFile();
}catch(IOException e){
Log.e("IOException", "exception in createNewFile() method");
}
//we have to bind the new file with a FileOutputStream
FileOutputStream os = null;
try{
os = new FileOutputStream(testFile);
}catch(FileNotFoundException e){
Log.e("FileNotFoundException", "can't create FileOutputStream");
}
PrintWriter pw = new PrintWriter(os);
pw.println("test");
pw.close();
Log.i(TAG,"wrote in: " + Environment.getExternalStorageDirectory()+ "/test.txt");
viernes, mayo 27, 2011
Install subclipse (subversion) in Eclipse in a few steps
To install Subclipse (subversion) repository plugin in Eclipse, do the following:
Note that you need internet connection :)
- 1. Open Eclipse
- 2. Help -> Install new software...
- 3. Click "Add.."
- 4. Add this repository (the name does not matter; the URL does):
http://subclipse.tigris.org/update_1.6.x
- 5. Type "subclipse" in the blank caption to search the plugin
- 6. Select it and install it
Note that you need internet connection :)
martes, marzo 15, 2011
Grooveshark: alternativa (también gratuita) a Spotify
¿Tienes problemas con Spotify?
¿No conoces las alternativas?
¿Quieres tener acceso a toda la música desde el propio navegador?
Grooveshark: http://listen.grooveshark.com
jueves, febrero 24, 2011
martes, diciembre 14, 2010
YouTube para el salón
Si eres de los que conecta el ordenador a la televisión y ve vídeos de YouTube desde el sofá de casa, seguro que te gustan estas versiones de YouTube.
La primera es una versión gigante, y se llama "XL":
La otra es una versión a pantalla completa, y se llama "Leanback":
a disfrutar!!!
La primera es una versión gigante, y se llama "XL":
http://www.youtube.com/xl
La otra es una versión a pantalla completa, y se llama "Leanback":
http://www.youtube.com/leanback
a disfrutar!!!
domingo, diciembre 12, 2010
LaTeX compiling error
If you are compiling a LaTeX document, and you get the following error:
! I can't find file `ptmr7t'Here you have the solution:
sudo apt-get install texlive-fonts-recommended
lunes, diciembre 06, 2010
Fix @ (at) character problem with Ubuntu in Macbook
If you can't write the @ character in Ubuntu, you should do this:
1. System > Preferences > Keyboard
2. Go to Keyboard Distribution label
3. Click Options
4. Look for something like "Key to access the third level" (sorry, my Ubuntu is Spanish ;-)
5. Select the key you are used to use when typing the @ symbol (I selected the "Alt" key)
That's all,
Enjoy!!
Some keywords for spanish readers: arreglar, problema, arroba, macbook, ubuntu
1. System > Preferences > Keyboard
2. Go to Keyboard Distribution label
3. Click Options
4. Look for something like "Key to access the third level" (sorry, my Ubuntu is Spanish ;-)
5. Select the key you are used to use when typing the @ symbol (I selected the "Alt" key)
That's all,
Enjoy!!
Some keywords for spanish readers: arreglar, problema, arroba, macbook, ubuntu
jueves, noviembre 18, 2010
Install Qt Ruby (qt4-qtruby) in Linux / Ubuntu
Hi!!
You only need to do this:
Maybe you need to install "qt4-dev-tools" if you do not have Qt4 libraries installed in your system.
Enjoy!!
PS: here I include a sample code to test if it works fine:
You only need to do this:
sudo apt-get install ruby libqt4-qtruby
Maybe you need to install "qt4-dev-tools" if you do not have Qt4 libraries installed in your system.
Enjoy!!
PS: here I include a sample code to test if it works fine:
require 'Qt4'
app = Qt::Application.new(ARGV)
window = Qt::Widget.new()
window.resize(200, 120)
quit = Qt::PushButton.new('Quit', window)
quit.font = Qt::Font.new('Times', 18, Qt::Font::Bold)
quit.setGeometry(10, 40, 180, 40)
Qt::Object.connect(quit, SIGNAL('clicked()'), app, SLOT('quit()'))
window.show()
app.exec()
miércoles, noviembre 10, 2010
Error while compiling Qt 4.7.1 in Debian Ubuntu (solved)
Did you get this error?:
You might need to modify the include and library search paths by editing QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11Just do this:
sudo apt-get install libx11-dev libfreetype6-dev libavahi-gobject-dev libSM-dev libXrender-dev libfontconfig-dev libXext-dev
Suscribirse a:
Entradas (Atom)