score:19
Accepted answer
Have a look at this this example here. I think the problem is that you don't configure the default file system using
conf.set("fs.defaultFS", "hdfs://quickstart.cloudera:8020")
and pass the relative path, like so:
fs.create(new Path("/tmp/mySample.txt"))
to write to the file, call 'write' directly on the output stream returned by fs.create, like so:
val os = fs.create(new Path("/tmp/mySample.txt"))
os.write("This is a test".getBytes)
Source: stackoverflow.com
Related Query
- How to write to HDFS using Scala
- How is scala generating byte code? Using some libraries like ASM, or write binary directly?
- How to write to HDFS using spark programming API if I have authentication details?
- How to read and write from MongoDb using two different drivers (MongoDB Scala Driver and Salat)
- How to write Scala tests for component "Write data to HDFS directory"
- How to write this for iteration in scala without using the For( loop; if condition) and still use yield properlly
- How to read a text file from HDFS in Scala natively (without using Spark)?
- How do write a date range query in mongodb using reactive mongo in scala
- How do I write a query for mongodb using the casbah driver for scala that uses a substring and checks if the field is in a list of supplied values?
- How to efficiently convert ListBuffer[ListBuffer[String]] into multiple dataframes and write them using Spark Scala
- how to read very big table from clickhouse to write it to hdfs using spark
- Using scala API, How do I copy all files of one HDFS location to another HDFS location
- How to Split HDFS file using Scala
- read from hdfs write to kafka using scala spark,but get NullPointerException
- How to get disk usage or sizes of files in a directory in a HDFS filesystem using Scala
- how to write a dataframe from scala to HDFS as csv
- How to update a mongo record using Rogue with MongoCaseClassField when case class contains a scala Enumeration
- How to parse JSON in Scala using standard Scala classes?
- Using partial functions in Scala - how does it work?
- Scala: How can I replace value in Dataframes using scala
- How do I call a Scala Object method using reflection?
- How to write "asInstanceOfOption" in Scala
- How to write Reads[T] and Writes[T] in scala Enumeration (play framework 2.1)
- scala how to write if else
- How to load JSON file using Play with Scala
- Write a simple json REST server using spray in scala
- How to groupBy using multiple columns in scala collections
- How can I avoid mutable variables in Scala when using ZipInputStreams and ZipOutpuStreams?
- How to set an expected exception using Scala and JUnit 4
- How do I write a scala unit test that ensures compliation fails?
More Query from same tag
- Since Scala lists are immutable, are they actually traversed at run-time for operations, length, last or xs(n)?
- mapping over zipped HLists
- How to compile this Scala code
- get first elements of clusters and clusters ids kmeans spark
- Proper way to terminate Scala Actor that only generates messages
- Mapping method to RDD in Spark
- Dependent classes and types
- Akka: how to unit testing OneForOneStrategy?
- Scala official documentation Variances example code
- A Function to rank the sequence of events based on transactions in a spark dataframe
- How to connect to ElasticSearch from Apache Spark Service on Bluemix
- Exact 1 year previous date in Scala
- Monad transformer in Scala for comprehension to handle Option and collect error messages
- Why is my algorithm for Project Euler Problem 12 so slow?
- Scala and Chef -- most recent Scala packages
- Scala - Android App build fails
- case class having primary constructor without having a no parameter in scala
- scala collections to string
- Spark Scala - Split Array of Structs into Dataframe Columns
- Can a scala object constructor be run twice as race condition?
- Compare timestamp columns - Spark scala
- how to get the annotation of a scala class field
- Clarification required regarding spark scala Array()
- Modeling a simple rule engine
- How to calculate the log loss metric in scala/spark?
- How many breaks does it take to divide a chocolate completely?
- Checking message query by actor in between calculations in scala/akka
- Configure ActorSystem in another library
- How can I use scala generators to generate date with range?
- scala lower bound type "with" another type?